{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}
module Network.Wai.Routing.Purescheme.Core.Header
( headerValue
)
where
import Network.Wai.Routing.Purescheme.Core.Basic
import Data.ByteString (ByteString)
import qualified Data.CaseInsensitive as CI
import Network.Wai (requestHeaders)
headerValue :: ByteString -> (Maybe ByteString -> GenericApplication b) -> GenericApplication b
ByteString
name Maybe ByteString -> GenericApplication b
f Request
req =
let
maybeValue :: Maybe ByteString
maybeValue = CI ByteString -> [(CI ByteString, ByteString)] -> Maybe ByteString
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup (ByteString -> CI ByteString
forall s. FoldCase s => s -> CI s
CI.mk ByteString
name) (Request -> [(CI ByteString, ByteString)]
requestHeaders Request
req)
in
Maybe ByteString -> GenericApplication b
f Maybe ByteString
maybeValue Request
req