aboutsummaryrefslogtreecommitdiff
path: root/src/Cana/Router.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Cana/Router.hs')
-rw-r--r--src/Cana/Router.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Cana/Router.hs b/src/Cana/Router.hs
new file mode 100644
index 0000000..1454375
--- /dev/null
+++ b/src/Cana/Router.hs
@@ -0,0 +1,20 @@
+-- |
+-- Module : Cana.Router
+
+module Cana.Router where
+
+import Cana.Types
+import Cana.Protocol
+import Cana.Monad
+
+import Network.URI
+
+-- | A predicate that always triggers, e.g. for catch-all routes.
+anyRoute :: Predicate
+anyRoute = const True
+
+-- | A predicate that matches the given hostname.
+routeHost :: String -> Predicate
+routeHost host request = case uriAuthority (requestUri request) of
+ Nothing -> False
+ Just auth -> uriRegName auth == host