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
  
  case response.header _ContentType of
    Nothing -> response.set_header _ContentType s .return
    Just _ -> response .return