module Network.Wai.Middleware.Routed (
routedMiddleware,
hostedMiddleware,
) where
import Data.ByteString (ByteString)
import Data.Text (Text)
import Network.Wai
routedMiddleware
:: ([Text] -> Bool)
-> Middleware
-> Middleware
routedMiddleware :: ([Text] -> Bool) -> Middleware -> Middleware
routedMiddleware [Text] -> Bool
pathCheck Middleware
middle Application
app Request
req
| [Text] -> Bool
pathCheck (Request -> [Text]
pathInfo Request
req) = Middleware
middle Application
app Request
req
| Bool
otherwise = Application
app Request
req
hostedMiddleware
:: ByteString
-> Middleware
-> Middleware
hostedMiddleware :: ByteString -> Middleware -> Middleware
hostedMiddleware ByteString
domain Middleware
middle Application
app Request
req
| ByteString -> Request -> Bool
hasDomain ByteString
domain Request
req = Middleware
middle Application
app Request
req
| Bool
otherwise = Application
app Request
req
hasDomain :: ByteString -> Request -> Bool
hasDomain :: ByteString -> Request -> Bool
hasDomain ByteString
domain Request
req = ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
domain Maybe ByteString -> Maybe ByteString -> Bool
forall a. Eq a => a -> a -> Bool
== Request -> Maybe ByteString
requestHeaderHost Request
req