{-# LANGUAGE RankNTypes #-}
module Airship.Headers
( addResponseHeader
, modifyResponseHeaders
) where
import Airship.Types (Webmachine, ResponseState(..))
import Control.Monad.State.Class (modify)
import Network.HTTP.Types (ResponseHeaders, Header)
modifyResponseHeaders :: Monad m => (ResponseHeaders -> ResponseHeaders) -> Webmachine m ()
modifyResponseHeaders f = modify updateHeaders
where updateHeaders rs@ResponseState{stateHeaders = h} = rs { stateHeaders = f h }
addResponseHeader :: Monad m => Header -> Webmachine m ()
addResponseHeader h = modifyResponseHeaders (h :)