summaryrefslogtreecommitdiff
path: root/Run
diff options
context:
space:
mode:
Diffstat (limited to 'Run')
-rw-r--r--Run/Que.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/Run/Que.hs b/Run/Que.hs
index 9893af2..356584f 100644
--- a/Run/Que.hs
+++ b/Run/Que.hs
@@ -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