diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index bb656dd..4e7bad9 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -193,12 +193,15 @@ instance Yesod App where defaultCsrfHeaderName defaultCsrfParamName ) - . ( \ handler -> do - host <- getsYesod $ appInstanceHost . appSettings - bs <- lookupHeaders hHost - case bs of - [b] | b == encodeUtf8 host -> handler - _ -> invalidArgs [hostMismatch host bs] + . ( \ handler -> + if developmentMode + then handler + else do + host <- getsYesod $ appInstanceHost . appSettings + bs <- lookupHeaders hHost + case bs of + [b] | b == encodeUtf8 host -> handler + _ -> invalidArgs [hostMismatch host bs] ) . defaultYesodMiddleware where diff --git a/src/Vervis/Settings.hs b/src/Vervis/Settings.hs index 55740e5..a2882ca 100644 --- a/src/Vervis/Settings.hs +++ b/src/Vervis/Settings.hs @@ -164,14 +164,17 @@ data AppSettings = AppSettings , appHighlightStyle :: Text } +developmentMode :: Bool +developmentMode = +#if DEVELOPMENT + True +#else + False +#endif + instance FromJSON AppSettings where parseJSON = withObject "AppSettings" $ \ o -> do - let defaultDev = -#if DEVELOPMENT - True -#else - False -#endif + let defaultDev = developmentMode appStaticDir <- o .: "static-dir" appDatabaseConf <- o .: "database" appMaxInstanceKeys <- o .:? "max-instance-keys"