X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FRouter.hs;h=657df3bb19cc76ea748edd0c008324a991c0c55c;hp=7c9c8055e56c81b1dbb9a5f4ac8e36e591255a37;hb=896da36;hpb=7bb9f322d85c1d7d8f23044a1be3b7e3b0ebe5b7 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"