module Network.Wai.Middleware.AddHeaders
( addHeaders
) where
import Control.Arrow (first)
import Data.ByteString (ByteString)
import qualified Data.CaseInsensitive as CI
import Network.HTTP.Types (Header)
import Network.Wai (Middleware, mapResponseHeaders, modifyResponse)
import Network.Wai.Internal (Response (..))
addHeaders :: [(ByteString, ByteString)] -> Middleware
[(ByteString, ByteString)]
h = (Response -> Response) -> Middleware
modifyResponse forall a b. (a -> b) -> a -> b
$ [Header] -> Response -> Response
addHeaders' (forall a b. (a -> b) -> [a] -> [b]
map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first forall s. FoldCase s => s -> CI s
CI.mk) [(ByteString, ByteString)]
h)
addHeaders' :: [Header] -> Response -> Response
[Header]
h = ([Header] -> [Header]) -> Response -> Response
mapResponseHeaders ([Header]
h forall a. [a] -> [a] -> [a]
++)