{-# LANGUAGE OverloadedStrings #-}
module Network.Wai.Middleware.MethodOverride
( methodOverride
) where
import Network.Wai
import Control.Monad (join)
-- | Allows overriding of the HTTP request method via the _method query string-- parameter.---- This middleware only applies when the initial request method is POST. This-- allow submitting of normal HTML forms, without worries of semantics-- mismatches in the HTTP spec.methodOverride :: MiddlewaremethodOverrideappreq =
appreq'
where
req' =
case (requestMethodreq, join$lookup"_method"$queryStringreq) of
("POST", Justm) -> req { requestMethod = m }
_ -> req