summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-16 20:03:34 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-16 20:03:34 +0100
commit08759871bcc3dc3b461650232747e58653535cdb (patch)
tree67834a75bbe5399f94a482880a23e0239af37a47
parentadf379f414ebd6f06cfe49dc481b220c7f141ba1 (diff)
downloadbar-08759871bcc3dc3b461650232747e58653535cdb.tar
bar-08759871bcc3dc3b461650232747e58653535cdb.tar.gz
bar-08759871bcc3dc3b461650232747e58653535cdb.tar.bz2
bar-08759871bcc3dc3b461650232747e58653535cdb.tar.xz
bar-08759871bcc3dc3b461650232747e58653535cdb.zip
Approot setting
-rw-r--r--Foundation.hs5
-rw-r--r--Settings.hs6
-rw-r--r--config/settings.yml1
3 files changed, 11 insertions, 1 deletions
diff --git a/Foundation.hs b/Foundation.hs
index d7425d5..27082fc 100644
--- a/Foundation.hs
+++ b/Foundation.hs
@@ -52,7 +52,10 @@ type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
52-- Please see the documentation for the Yesod typeclass. There are a number 52-- Please see the documentation for the Yesod typeclass. There are a number
53-- of settings which can be configured by overriding methods here. 53-- of settings which can be configured by overriding methods here.
54instance Yesod App where 54instance Yesod App where
55 approot = ApprootRequest $ \_ req -> maybe "" (TE.decodeUtf8With TEE.lenientDecode) $ Map.lookup "AppRoot" (Map.fromList $ requestHeaders req) 55 approot = ApprootRequest $ \app req ->
56 case appRoot $ appSettings app of
57 Nothing -> getApprootText guessApproot app req
58 Just root -> root
56 59
57 -- Store session data on the client in encrypted cookies, 60 -- Store session data on the client in encrypted cookies,
58 -- default session idle timeout is 120 minutes 61 -- default session idle timeout is 120 minutes
diff --git a/Settings.hs b/Settings.hs
index a15fb03..8a98c7a 100644
--- a/Settings.hs
+++ b/Settings.hs
@@ -35,6 +35,7 @@ data AppSettings = AppSettings
35 -- ^ Directory from which to serve static files. 35 -- ^ Directory from which to serve static files.
36 , appDatabaseConf :: PostgresConf 36 , appDatabaseConf :: PostgresConf
37 -- ^ Configuration settings for accessing the database. 37 -- ^ Configuration settings for accessing the database.
38 , appRoot :: Maybe Text
38 , appHost :: HostPreference 39 , appHost :: HostPreference
39 -- ^ Host/interface the server should bind to. 40 -- ^ Host/interface the server should bind to.
40 , appPort :: Int 41 , appPort :: Int
@@ -59,6 +60,11 @@ instance FromJSON AppSettings where
59 parseUrl' = either (fail . show) return . parseBaseUrl 60 parseUrl' = either (fail . show) return . parseBaseUrl
60 appStaticDir <- o .: "static-dir" 61 appStaticDir <- o .: "static-dir"
61 appDatabaseConf <- o .: "database" 62 appDatabaseConf <- o .: "database"
63 appRoot' <- o .:? "approot"
64 let
65 appRoot
66 | appRoot' == Just "" = Nothing
67 | otherwise = appRoot'
62 appHost <- fromString <$> o .: "host" 68 appHost <- fromString <$> o .: "host"
63 appPort <- o .: "port" 69 appPort <- o .: "port"
64 appIpFromHeader <- o .: "ip-from-header" 70 appIpFromHeader <- o .: "ip-from-header"
diff --git a/config/settings.yml b/config/settings.yml
index c867908..f6332bd 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -1,4 +1,5 @@
1static-dir: "_env:STATIC_DIR:static" 1static-dir: "_env:STATIC_DIR:static"
2approot: "_env:APPROOT:"
2host: "_env:HOST:*4" # any IPv4 host 3host: "_env:HOST:*4" # any IPv4 host
3port: "_env:PORT:3000" 4port: "_env:PORT:3000"
4ip-from-header: "_env:IP_FROM_HEADER:false" 5ip-from-header: "_env:IP_FROM_HEADER:false"