diff options
-rw-r--r-- | Run/Que/Server.hs | 14 | ||||
-rw-r--r-- | Run/Que/service.nix | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/Run/Que/Server.hs b/Run/Que/Server.hs index ba7ac86..e0327a5 100644 --- a/Run/Que/Server.hs +++ b/Run/Que/Server.hs @@ -28,7 +28,6 @@ import qualified Data.Text.Encoding as Encoding import Data.Text.Lazy ( Text , fromStrict ) -import qualified Data.Text.Lazy as Text import qualified Network.HTTP.Types.Status as Http import qualified Network.Socket as Socket import qualified Network.Wai as Wai @@ -80,8 +79,8 @@ routes :: Scotty.ScottyT Text App () routes = do Scotty.middleware logStdout - let quepath = "^/([[:alnum:]_]+)/([[:alnum:]._/]*)$" - let namespace = "^/([[:alnum:]_]+)/?$" -- matches '/ns' and '/ns/' but not '/ns/path' + let quepath = "^\\/([[:alnum:]_]+)\\/([[:alnum:]._/]*)$" + let namespace = "^\\/([[:alnum:]_]+)\\/?$" -- matches '/ns' and '/ns/' but not '/ns/path' -- | GET /index.html Scotty.get (Scotty.literal "/index.html") <| Scotty.redirect "/_/index" @@ -112,7 +111,7 @@ routes = do -- -- Put a value on a que. Returns immediately. Scotty.post (Scotty.regex quepath) <| do - r <- Scotty.request + r <- Scotty.request (ns, qp) <- extract -- "_" is a special, internal namespace that only I can use when ("_" == ns) <| guardIP r @@ -158,10 +157,9 @@ insertQue ns qp q as = as { ques = newQues } extract :: Scotty.ActionT Text App (Namespace, Quepath) extract = do - ns <- Scotty.param "0" - path <- Scotty.param "1" - let p = Text.split (== '/') path |> filter (not . Text.null) - return (ns, p) + ns <- Scotty.param "1" + path <- Scotty.param "2" + return (ns, path) newtype App a = App { runApp :: ReaderT (STM.TVar AppState) IO a diff --git a/Run/Que/service.nix b/Run/Que/service.nix index b9f5c19..1d82bd6 100644 --- a/Run/Que/service.nix +++ b/Run/Que/service.nix @@ -60,6 +60,10 @@ in enableACME = true; locations."/" = { proxyPass = "http://localhost:${toString cfg.port}"; + extraConfig = '' + # forward the headers so the `guardIP` function works properly + proxy_pass_request_headers on; + ''; }; }; }; |