-- | 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.Constants
import Hack.Contrib.Response
import MPS.Light
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