hack-contrib-2009.6.25: src/Hack/Contrib/Middleware/Head.hs
module Hack.Contrib.Middleware.Head (head) where
import Hack
import Hack.Contrib.Response
import Hack.Contrib.Utils
import MPS.Light
import Prelude hiding ((.), (^), (>), head)
import qualified Data.ByteString.Lazy.Char8 as B
head :: Middleware
head app = \env -> do
response <- app env
if env.request_method.is HEAD
then response .set_body B.empty .set_content_length 0 .return
else response .return