From: PHO Date: Fri, 6 Jan 2012 13:27:33 +0000 (+0900) Subject: working on Router arrow X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=896da36;p=Lucu.git working on Router arrow Ditz-issue: c80e79a2585ac20cc5ed677d70b6983a2842a81d --- diff --git a/Network/HTTP/Lucu/Httpd.hs b/Network/HTTP/Lucu/Httpd.hs index a5f9749..6f4b34d 100644 --- a/Network/HTTP/Lucu/Httpd.hs +++ b/Network/HTTP/Lucu/Httpd.hs @@ -50,6 +50,7 @@ import Prelude.Unicode -- 'Network.HTTP.Lucu.putChunk' \"Hello, world!\" -- } -- @ +-- FIXME: use monad-parallel's MonadFork instead of IO. runHttpd ∷ HostMapper α ⇒ Config → α → IO () runHttpd cnf hm = do let launchers diff --git a/Network/HTTP/Lucu/Router.hs b/Network/HTTP/Lucu/Router.hs index 7c9c805..657df3b 100644 --- a/Network/HTTP/Lucu/Router.hs +++ b/Network/HTTP/Lucu/Router.hs @@ -12,6 +12,7 @@ module Network.HTTP.Lucu.Router , runRouter -- * Testing for URI scheme + , anyScheme , schemeWith , scheme , http @@ -50,6 +51,11 @@ runRouter ∷ (Applicative m, MonadIO m) ⇒ Router m α β → α → m (Maybe {-# INLINE runRouter #-} runRouter = ((listToMaybe <$>) ∘) ∘ runListTArrow ∘ unRouter +-- |FIXME: doc +anyScheme ∷ Arrow (⇝) ⇒ URI ⇝ (Host, Path) +{-# INLINEABLE anyScheme #-} +anyScheme = arr uriHost &&& arr uriPathSegments + -- |FIXME: doc schemeWith ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ (CIAscii → Bool) @@ -58,7 +64,7 @@ schemeWith ∷ (ArrowChoice (⇝), ArrowZero (⇝)) schemeWith f = proc uri → if f (uriCIScheme uri) then - arr uriHost &&& arr uriPathSegments ⤙ uri + anyScheme ⤙ uri else zeroArrow ⤙ (⊥) @@ -72,10 +78,10 @@ http ∷ (ArrowChoice (⇝), ArrowPlus (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host {-# INLINE http #-} http = scheme "http" <+> scheme "https" --- |@'http'' = 'scheme' \"http\" +-- |@'http'' = 'scheme' \"http\"@ http' ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path) http' = scheme "http" --- |@'https' = 'scheme' \"https\" +-- |@'https' = 'scheme' \"https\"@ https ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path) https = scheme "https"