diff --git a/CHANGELOG.md b/CHANGELOG.md index 2261f7d16..edb6105d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- #896, Boolean env var interpolation in config file - @begriffs + ## [0.4.2.0] - 2017-06-11 ### Added diff --git a/src/PostgREST/Config.hs b/src/PostgREST/Config.hs index 13514c687..e73a7b663 100644 --- a/src/PostgREST/Config.hs +++ b/src/PostgREST/Config.hs @@ -111,7 +111,7 @@ readOptions = do <*> (fromMaybe "*4" <$> C.key "server-host") <*> (fromMaybe 3000 . join . fmap coerceInt <$> C.key "server-port") <*> (fmap encodeUtf8 . mfilter (/= "") <$> C.key "jwt-secret") - <*> (fromMaybe False <$> C.key "secret-is-base64") + <*> (fromMaybe False . join . fmap coerceBool <$> C.key "secret-is-base64") <*> (fromMaybe 10 . join . fmap coerceInt <$> C.key "db-pool") <*> (join . fmap coerceInt <$> C.key "max-rows") <*> C.key "pre-request" @@ -130,6 +130,11 @@ readOptions = do coerceInt (String x) = readMaybe $ toS x coerceInt _ = Nothing + coerceBool :: Value -> Maybe Bool + coerceBool (Bool b) = Just b + coerceBool (String x) = readMaybe $ toS x + coerceBool _ = Nothing + opts = info (helper <*> pathParser) $ fullDesc <> progDesc (