on master help sign in
MethodOverride: only on POST
commite330456ef794cc618cc3ea2cf9b263182db5a7da authorMichael Snoyman <michael@snoyman.com> dateMon 16 Apr 2012, 12:17 (15 years ago) parente1f581b
1 file changed+7−3
wai-extra/Network/Wai/Middleware/MethodOverride.hs+7−3
wai-extra/Network/Wai/Middleware/MethodOverride.hs+7−3
@@ -8,11 +8,15 @@ import Control.Monad (join)
88
99-- | Allows overriding of the HTTP request method via the _method query string
1010-- parameter.
11+--
12+-- This middlware only applies when the initial request method is POST. This
13+-- allow submitting of normal HTML forms, without worries of semantics
14+-- mismatches in the HTTP spec.
1115methodOverride :: Middleware
1216methodOverride app req =
1317 app req'
1418 where
1519 req' =
16− case join $ lookup "_method" $ queryString req of
17− Nothing -> req
18− Just m -> req { requestMethod = m }
20+ case (requestMethod m, join $ lookup "_method" $ queryString req) of
21+ ("POST", Just m) -> req { requestMethod = m }
22+ _ -> req