diff options
Diffstat (limited to 'Run/Que.hs')
-rw-r--r-- | Run/Que.hs | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -82,6 +82,24 @@ routes = do Scotty.middleware logStdoutDev let quepath = "^/([[:alnum:]_]*)/([[:alnum:]_/]*)$" + let index = "^(/|/index.html)$" + + Scotty.get (Scotty.regex index) <| do + let (ns, qp) = ("_", ["index"]) + app . modify <| upsertNamespace ns + q <- app <| que ns qp + r <- liftIO <| takeQue q + Scotty.html <| fromStrict <| Encoding.decodeUtf8 r + + Scotty.post (Scotty.regex index) <| do + r <- Scotty.request + guardIP r + let (ns, qp) = ("_", ["index"]) + app . modify <| upsertNamespace ns + q <- app <| que ns qp + qdata <- Scotty.body + liftIO <| pushQue (BSL.toStrict qdata) q + return () Scotty.matchAny (Scotty.regex "^/([[:alnum:]_]*)/?$") <| do -- matches '/ns' and '/ns/' but not '/ns/path' @@ -101,7 +119,7 @@ routes = do True -> Scotty.stream $ streamQue q _ -> do r <- liftIO <| takeQue q - Scotty.text <| fromStrict <| Encoding.decodeUtf8 r + Scotty.html <| fromStrict <| Encoding.decodeUtf8 r -- | Put a value on a que. Returns immediately. Scotty.post (Scotty.regex quepath) <| do |