summaryrefslogtreecommitdiff
path: root/Router.hs
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2020-11-26 16:51:52 +0400
committerAndrew <saintruler@gmail.com>2020-11-26 16:51:52 +0400
commit6907a35ac265c4d4eeb127befea481a84e59ad4a (patch)
treec115faf536fe82d0e2a998a4b8a1529e3b6ccf16 /Router.hs
parent446602fe336ad1c2a23e3d50d7cd1d1356fcc9de (diff)
Added Http parsing
Diffstat (limited to 'Router.hs')
-rw-r--r--Router.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/Router.hs b/Router.hs
index 4798ec1..cad4bc8 100644
--- a/Router.hs
+++ b/Router.hs
@@ -4,6 +4,7 @@ import Control.Exception
import Response
import Request
+-- Route callback url method
data Route = Route (Request -> IO Response) String String
data RouterError = RouteNotFound
@@ -11,11 +12,9 @@ data RouterError = RouteNotFound
instance Exception RouterError
-getResponse [] _ = throw RouteNotFound
-getResponse (Route callback routeUrl _ : routerTable) req @ (Request _ url _) =
+resolve :: [Route] -> Request -> IO Response
+resolve [] _ = return notFoundResponse
+resolve (Route callback routeUrl _ : routerTable) req @ (Request _ url _) =
if url == routeUrl then
callback req
- else getResponse routerTable req
-
-router table req =
-
+ else resolve routerTable req