Make hostname configurable
This commit is contained in:
+1
-4
@@ -19,7 +19,6 @@ import qualified Hasql.Decoders as HD
|
|||||||
import qualified Hasql.Encoders as HE
|
import qualified Hasql.Encoders as HE
|
||||||
import qualified Hasql.Pool as P
|
import qualified Hasql.Pool as P
|
||||||
import Network.Wai.Handler.Warp
|
import Network.Wai.Handler.Warp
|
||||||
import Network.BSD (getHostName)
|
|
||||||
import System.IO (BufferMode (..),
|
import System.IO (BufferMode (..),
|
||||||
hSetBuffering, stderr,
|
hSetBuffering, stderr,
|
||||||
stdin, stdout)
|
stdin, stdout)
|
||||||
@@ -47,9 +46,7 @@ main = do
|
|||||||
hSetBuffering stdin LineBuffering
|
hSetBuffering stdin LineBuffering
|
||||||
hSetBuffering stderr NoBuffering
|
hSetBuffering stderr NoBuffering
|
||||||
|
|
||||||
conf' <- readOptions
|
conf <- readOptions
|
||||||
host <- getHostName
|
|
||||||
let conf = conf'{configHost = host}
|
|
||||||
let port = configPort conf
|
let port = configPort conf
|
||||||
pgSettings = cs (configDatabase conf)
|
pgSettings = cs (configDatabase conf)
|
||||||
appSettings = setPort port
|
appSettings = setPort port
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ executable postgrest
|
|||||||
, insert-ordered-containers >= 0.1.0.1
|
, insert-ordered-containers >= 0.1.0.1
|
||||||
, http-media >= 0.6.3
|
, http-media >= 0.6.3
|
||||||
, swagger2 >= 2.1
|
, swagger2 >= 2.1
|
||||||
, network >= 2.6.2.1
|
|
||||||
, HTTP
|
, HTTP
|
||||||
, Ranged-sets
|
, Ranged-sets
|
||||||
if !os(windows)
|
if !os(windows)
|
||||||
@@ -116,7 +115,6 @@ library
|
|||||||
, insert-ordered-containers >= 0.1.0.1
|
, insert-ordered-containers >= 0.1.0.1
|
||||||
, http-media >= 0.6.3
|
, http-media >= 0.6.3
|
||||||
, swagger2 >= 2.1
|
, swagger2 >= 2.1
|
||||||
, network >= 2.6.2.1
|
|
||||||
|
|
||||||
Other-Modules: Paths_postgrest
|
Other-Modules: Paths_postgrest
|
||||||
Exposed-Modules: PostgREST.App
|
Exposed-Modules: PostgREST.App
|
||||||
@@ -198,6 +196,5 @@ Test-Suite spec
|
|||||||
, insert-ordered-containers
|
, insert-ordered-containers
|
||||||
, http-media
|
, http-media
|
||||||
, swagger2
|
, swagger2
|
||||||
, network
|
|
||||||
, HTTP
|
, HTTP
|
||||||
, Ranged-sets
|
, Ranged-sets
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ argParser = AppConfig
|
|||||||
<$> argument str (help "(REQUIRED) database connection string, e.g. postgres://user:pass@host:port/db" <> metavar "DB_URL")
|
<$> argument str (help "(REQUIRED) database connection string, e.g. postgres://user:pass@host:port/db" <> metavar "DB_URL")
|
||||||
<*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE")
|
<*> strOption (long "anonymous" <> short 'a' <> help "(REQUIRED) postgres role to use for non-authenticated requests" <> metavar "ROLE")
|
||||||
<*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault)
|
<*> strOption (long "schema" <> short 's' <> help "schema to use for API routes" <> metavar "NAME" <> value "public" <> showDefault)
|
||||||
<*> pure "localhost"
|
<*> strOption (long "hostname" <> short 'n' <> help "hostname on which the HTTP server is running" <> metavar "HOSTNAME" <> value "localhost" <> showDefault)
|
||||||
<*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault)
|
<*> option auto (long "port" <> short 'p' <> help "port number on which to run HTTP server" <> metavar "PORT" <> value 3000 <> showDefault)
|
||||||
<*> (secret . cs <$>
|
<*> (secret . cs <$>
|
||||||
strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault))
|
strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault))
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ extra-deps:
|
|||||||
- insert-ordered-containers-0.1.0.1
|
- insert-ordered-containers-0.1.0.1
|
||||||
- swagger2-2.1
|
- swagger2-2.1
|
||||||
- http-media-0.6.3
|
- http-media-0.6.3
|
||||||
- network-2.6.2.1
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
postgrest: -O2 -Werror -Wall -fwarn-identities
|
postgrest: -O2 -Werror -Wall -fwarn-identities
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user