refactor: move parseSecret out of App.postgrest

parseSecret only needs to be computed once, after the config is read.
This commit is contained in:
steve-chavez
2020-07-13 11:30:16 -05:00
committed by Steve Chavez
parent 96a16a377f
commit 0ff05edd16
5 changed files with 43 additions and 30 deletions
+4 -1
View File
@@ -28,6 +28,7 @@ import Network.Wai.Handler.Warp (defaultSettings, runSettings,
import System.IO (BufferMode (..), hSetBuffering)
import PostgREST.App (postgrest)
import PostgREST.Auth (parseSecret)
import PostgREST.Config (AppConfig (..), configPoolTimeout',
prettyVersion, readAppConfig, readPathShowHelp, loadDbUriFile, loadSecretFile)
import PostgREST.DbStructure (getDbStructure, getPgVersion)
@@ -203,7 +204,9 @@ main = do
path <- readPathShowHelp
-- build the 'AppConfig' from the config file path
conf <- loadDbUriFile =<< loadSecretFile =<< readAppConfig path
conf <- do
cnf <- loadDbUriFile =<< loadSecretFile =<< readAppConfig path
pure cnf { configJWKS = parseSecret <$> configJwtSecret cnf}
-- Checks that the provided proxy uri is formated correctly
when (isMalformedProxyUri $ toS <$> configOpenAPIProxyUri conf) $