Add proxy awareness for OpenAPI spec generation

Proxy uri from command line options takes precedence over host and port
This commit is contained in:
Jacky Hu
2016-07-07 19:20:40 +08:00
parent 63046baffd
commit 1fef1991ef
12 changed files with 188 additions and 45 deletions
+5
View File
@@ -8,6 +8,7 @@ import PostgREST.Config (AppConfig (..),
minimumPgVersion,
prettyVersion,
readOptions)
import PostgREST.OpenAPI (isMalformedProxyUri)
import PostgREST.DbStructure
import Control.Monad
@@ -50,12 +51,16 @@ main = do
conf <- readOptions
let host = configHost conf
port = configPort conf
proxy = configProxyUri conf
pgSettings = cs (configDatabase conf)
appSettings = setHost (fromString host)
. setPort port
. setServerName (cs $ "postgrest/" <> prettyVersion)
$ defaultSettings
when (isMalformedProxyUri proxy) $ error
"Malformed proxy uri, a correct example: https://example.com:8443/basePath"
unless (secret "secret" /= configJwtSecret conf) $
putStrLn "WARNING, running in insecure mode, JWT secret is the default value"
Prelude.putStrLn $ "Listening on port " ++