Plack::Middleware::MethodOverride - Override REST methods to Plack apps
In your Plack app:
PUT via a query parameter in your POST forms:
Or override it via the X-HTTP-Method-Override header in a request:
my $req = HTTP::Request->new(POST => '/foo', [
'X-HTTP-Method-Override' => 'PUT'
is a good thing, but if you're also trying to support web browsers, it
would be nice not to be reduced to GET and POST for everything.
This middleware allows for POST requests that pretend to be something
else: by adding either a header named X-HTTP-Method-Override to the
request, or a query parameter named x-tunneled-method to the URI, the
client can say what method it actually meant. That is, as long as it
meant one of these:
If so, then the REQUEST_METHOD in the PSGI environment will be replaced
with the client's desired value. The original request method is always
stored under the plack.original_request_method key.
These are the named arguments you can pass to new. Or, more likely, on
the enable line in your builder block, as in
enable 'MethodOverride', header => 'X-HTTP-Method', param => 'my_method';
Specifies the HTTP header name which specifies the overriding HTTP
Defaults to X-HTTP-Method-Override, as used by Google for its APIs.
Specifies the query parameter name to specify the overriding HTTP
Defaults to x-tunneled-method.
David E. Wheeler
2015- Tatsuhiko Miyagawa, David E. Wheeler, Aristotle Pagaltzis
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
This module gleefully steals from
Catalyst::TraitFor::Request::REST::ForBrowsers by Dave Rolsky and the
original version by Tatsuhiko Miyagawa (which in turn stole from
HTTP::Engine::Middleware::MethodOverride). Thanks to Aristotle
Pagaltzis for the shove in this direction, to
Matt S Trout for suggesting that it be
implemented as middleware, and to Hans Dieter Pearcey
for convincing me not to parse body