diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-11 22:41:16 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-11 22:41:16 +0100 |
commit | 24148102292ba2f327546c8a97dddb7dcae3aec4 (patch) | |
tree | d1b617f944e65a82731bdd6b6b4d2326adb33024 /bragi | |
parent | 211086aa91b5ed7f9525bf82793fc8525a55f185 (diff) | |
download | nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.gz nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.bz2 nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.xz nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.zip |
Send AppRoot via HTTP header
Diffstat (limited to 'bragi')
-rwxr-xr-x | bragi/bar.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bragi/bar.hs b/bragi/bar.hs index 61d24119..1cf10fdf 100755 --- a/bragi/bar.hs +++ b/bragi/bar.hs | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | import Yesod | 20 | import Yesod |
21 | import Database.Persist.Postgresql | 21 | import Database.Persist.Postgresql |
22 | import Network.Wai (requestHeaders) | ||
22 | 23 | ||
23 | import Control.Monad.Logger (runStderrLoggingT) | 24 | import Control.Monad.Logger (runStderrLoggingT) |
24 | import Control.Monad.Reader | 25 | import Control.Monad.Reader |
@@ -32,6 +33,9 @@ import Data.Time.Format | |||
32 | import Data.Text (Text) | 33 | import Data.Text (Text) |
33 | import qualified Data.Text as Text | 34 | import qualified Data.Text as Text |
34 | 35 | ||
36 | import qualified Data.Text.Encoding as TE | ||
37 | import qualified Data.Text.Encoding.Error as TEE | ||
38 | |||
35 | import Data.Map.Lazy (Map) | 39 | import Data.Map.Lazy (Map) |
36 | import qualified Data.Map.Lazy as Map | 40 | import qualified Data.Map.Lazy as Map |
37 | 41 | ||
@@ -124,7 +128,7 @@ mkYesod "BarInventory" [parseRoutes| | |||
124 | |] | 128 | |] |
125 | 129 | ||
126 | instance Yesod BarInventory where | 130 | instance Yesod BarInventory where |
127 | approot = guessApproot | 131 | approot = ApprootRequest $ \_ req -> maybe "" (TE.decodeUtf8With TEE.lenientDecode) $ Map.lookup "AppRoot" (Map.fromList $ requestHeaders req) |
128 | 132 | ||
129 | instance RenderMessage BarInventory FormMessage where | 133 | instance RenderMessage BarInventory FormMessage where |
130 | renderMessage _ _ = defaultFormMessage | 134 | renderMessage _ _ = defaultFormMessage |