diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index 5aaccf9a7..5cddcec12 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -43,6 +43,7 @@ data AppConfig = AppConfig { , configJwtSecret :: Secret , configPool :: Int , configMaxRows :: Maybe Integer + , configQuiet :: Bool } argParser :: Parser AppConfig @@ -55,6 +56,7 @@ argParser = AppConfig strOption (long "jwt-secret" <> short 'j' <> help "secret used to encrypt and decrypt JWT tokens" <> metavar "SECRET" <> value "secret" <> showDefault)) <*> option auto (long "pool" <> short 'o' <> help "max connections in database pool" <> metavar "COUNT" <> value 10 <> showDefault) <*> (readMay <$> strOption (long "max-rows" <> short 'm' <> help "max rows in response" <> metavar "COUNT" <> value "infinity" <> showDefault)) + <*> pure False defaultCorsPolicy :: CorsResourcePolicy defaultCorsPolicy = CorsResourcePolicy Nothing diff --git a/src/PostgREST/Main.hs b/src/PostgREST/Main.hs index c8931da2a..98efe5f19 100644 --- a/src/PostgREST/Main.hs +++ b/src/PostgREST/Main.hs @@ -88,7 +88,7 @@ main = do postgrest :: AppConfig -> DbStructure -> P.Pool -> Application postgrest conf dbStructure pool = - let middle = logStdout . defaultMiddle in + let middle = (if configQuiet conf then id else logStdout) . defaultMiddle in middle $ \ req respond -> do time <- getPOSIXTime diff --git a/test/Main.hs b/test/Main.hs index f3e9f91e1..01416a100 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -23,11 +23,11 @@ main :: IO () main = do setupDb - pool <- P.acquire (10, 10, cs dbString) + pool <- P.acquire (10, 10, cs testDbConn) result <- P.use pool $ getDbStructure "test" let dbStructure = either (error.show) id result - withApp = return $ postgrest cfgDefault dbStructure pool + withApp = return $ postgrest testCfg dbStructure pool hspec . sequence_ . map (before withApp) $ specs diff --git a/test/SpecHelper.hs b/test/SpecHelper.hs index db386d3f3..be8a9e94f 100644 --- a/test/SpecHelper.hs +++ b/test/SpecHelper.hs @@ -14,17 +14,12 @@ import Web.JWT (secret) import PostgREST.Config (AppConfig(..)) -dbString :: String -dbString = "postgres://postgrest_test_authenticator@localhost:5432/postgrest_test" +testDbConn :: String +testDbConn = "postgres://postgrest_test_authenticator@localhost:5432/postgrest_test" -cfg :: String -> Maybe Integer -> AppConfig -cfg conStr = AppConfig conStr "postgrest_test_anonymous" "test" 3000 (secret "safe") 10 - -cfgDefault :: AppConfig -cfgDefault = cfg dbString Nothing - -cfgLimitRows :: Integer -> AppConfig -cfgLimitRows = cfg dbString . Just +testCfg :: AppConfig +testCfg = + AppConfig testDbConn "postgrest_test_anonymous" "test" 3000 (secret "safe") 10 Nothing True setupDb :: IO () setupDb = do