summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-11 22:41:16 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-11 22:41:16 +0100
commit24148102292ba2f327546c8a97dddb7dcae3aec4 (patch)
treed1b617f944e65a82731bdd6b6b4d2326adb33024
parent211086aa91b5ed7f9525bf82793fc8525a55f185 (diff)
downloadnixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar
nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.gz
nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.bz2
nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.tar.xz
nixos-24148102292ba2f327546c8a97dddb7dcae3aec4.zip
Send AppRoot via HTTP header
-rw-r--r--bragi.nix1
-rwxr-xr-xbragi/bar.hs6
2 files changed, 6 insertions, 1 deletions
diff --git a/bragi.nix b/bragi.nix
index cc8c5976..d00f2598 100644
--- a/bragi.nix
+++ b/bragi.nix
@@ -369,6 +369,7 @@ in rec {
369 } 369 }
370 370
371 location /bar/ { 371 location /bar/ {
372 proxy_set_header AppRoot "http://$server_name/bar";
372 proxy_pass http://localhost:8082/; 373 proxy_pass http://localhost:8082/;
373 } 374 }
374 } 375 }
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
20import Yesod 20import Yesod
21import Database.Persist.Postgresql 21import Database.Persist.Postgresql
22import Network.Wai (requestHeaders)
22 23
23import Control.Monad.Logger (runStderrLoggingT) 24import Control.Monad.Logger (runStderrLoggingT)
24import Control.Monad.Reader 25import Control.Monad.Reader
@@ -32,6 +33,9 @@ import Data.Time.Format
32import Data.Text (Text) 33import Data.Text (Text)
33import qualified Data.Text as Text 34import qualified Data.Text as Text
34 35
36import qualified Data.Text.Encoding as TE
37import qualified Data.Text.Encoding.Error as TEE
38
35import Data.Map.Lazy (Map) 39import Data.Map.Lazy (Map)
36import qualified Data.Map.Lazy as Map 40import qualified Data.Map.Lazy as Map
37 41
@@ -124,7 +128,7 @@ mkYesod "BarInventory" [parseRoutes|
124|] 128|]
125 129
126instance Yesod BarInventory where 130instance Yesod BarInventory where
127 approot = guessApproot 131 approot = ApprootRequest $ \_ req -> maybe "" (TE.decodeUtf8With TEE.lenientDecode) $ Map.lookup "AppRoot" (Map.fromList $ requestHeaders req)
128 132
129instance RenderMessage BarInventory FormMessage where 133instance RenderMessage BarInventory FormMessage where
130 renderMessage _ _ = defaultFormMessage 134 renderMessage _ _ = defaultFormMessage