hack-contrib-2009.4.52: src/Hack/Contrib/Middleware/ContentType.hs
-- | Stolen from rack: Sets the Content-Type header on responses which don't have one.
module Hack.Contrib.Middleware.ContentType (content_type) where
import Hack
import Hack.Contrib.Response
import Hack.Contrib.Constants
import MPSUTF8
import Prelude hiding ((.), (^), (>))
content_type :: String -> Middleware
content_type s app = \env -> do
response <- app env
return $ case response.header _ContentType of
Nothing -> response.set_header _ContentType s
Just _ -> response