refactor: separate reading file from parsing it

This commit is contained in:
steve-chavez
2020-07-13 11:30:16 -05:00
committed by Steve Chavez
parent 343e41c51d
commit 896b79f05b
3 changed files with 95 additions and 83 deletions
+6 -3
View File
@@ -31,7 +31,7 @@ import System.IO (BufferMode (..), hSetBuffering)
import PostgREST.App (postgrest)
import PostgREST.Config (AppConfig (..), configPoolTimeout',
prettyVersion, readOptions)
prettyVersion, readAppConfig, readPath)
import PostgREST.DbStructure (getDbStructure, getPgVersion)
import PostgREST.Error (PgError (PgError), checkIsFatal,
errorPayload)
@@ -200,10 +200,13 @@ main = do
hSetBuffering stdout LineBuffering
hSetBuffering stdin LineBuffering
hSetBuffering stderr NoBuffering
--
path <- readPath
-- readOptions builds the 'AppConfig' from the config file specified on the
-- command line
conf <- loadDbUriFile =<< loadSecretFile =<< readOptions
conf <- loadDbUriFile =<< loadSecretFile =<< readAppConfig path
let schemas = toList $ configSchemas conf
host = configHost conf
port = configPort conf