summaryrefslogtreecommitdiff
path: root/Run/Que/Server.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Run/Que/Server.hs')
-rw-r--r--Run/Que/Server.hs14
1 files changed, 6 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