3 , GeneralizedNewtypeDeriving
9 module Network.HTTP.Lucu.Router
10 ( -- * The 'Router' arrow
14 -- * Testing for URI scheme
22 import Control.Applicative
23 import Control.Category
25 import Control.Arrow.ArrowKleisli
26 import Control.Arrow.List
27 import Control.Monad.IO.Class
28 import Data.Ascii (CIAscii)
30 import Network.URI hiding (scheme)
31 import Network.HTTP.Lucu.Utils
32 import Prelude.Unicode
37 unRouter ∷ ListTArrow m α β
49 runRouter ∷ (Applicative m, MonadIO m) ⇒ Router m α β → α → m (Maybe β)
50 {-# INLINE runRouter #-}
51 runRouter = ((listToMaybe <$>) ∘) ∘ runListTArrow ∘ unRouter
54 anyScheme ∷ Arrow (⇝) ⇒ URI ⇝ (Host, Path)
55 {-# INLINEABLE anyScheme #-}
56 anyScheme = arr uriHost &&& arr uriPathSegments
59 scheme ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ CIAscii → URI ⇝ (Host, Path)
60 {-# INLINEABLE scheme #-}
63 if s ≡ uriCIScheme uri then
68 -- |@'http' = 'scheme' \"http\" '<+>' 'scheme' \"https\"@
69 http ∷ (ArrowChoice (⇝), ArrowPlus (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path)
71 http = scheme "http" <+> scheme "https"
73 -- |@'http'' = 'scheme' \"http\"@
74 http' ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path)
77 -- |@'https' = 'scheme' \"https\"@
78 https ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path)
79 https = scheme "https"