Plack:...verride(3pm)
π Plack::Middleware::MethodOverride β the 3pm glow-up π
okay bestie, so this is a User Contributed Perl Documentation page (you know, the 3pm kind, perl people's lil library manual section) and it's literally about letting your sad little browser-only app do real REST verbs. no cap. π¦
β¨ Name β¨
Plack::Middleware::MethodOverride β Override REST methods to Plack apps via POST
πΈ Version πΈ
version 0.20 β she's a specific girlie, remember that π
π Synopsis π
In your Plack app, it's giving:
use Plack::Builder;
builder {
enable MethodOverride;
$app;
};
Want to PUT via a query parameter in your POST forms? say less:
<form method="POST" action="/foo?x-tunneled-method=PUT">
<!-- ... -->
</form>
Or override it via the X-HTTP-Method-Override header in a request, main character style:
my $req = HTTP::Request->new(POST => '/foo', [
'X-HTTP-Method-Override' => 'PUT'
]);
π Description π
Writing REST <http://en.wikipedia.org/wiki/Representational_State_Transfer>ful apps is a good thing, lowkey iconic even. but if you're also trying to support web browsers, it would be nice not to be reduced to GET and POST for literally everything π
This middleware lets POST requests pretend to be something else. the way it works: the client adds either a header named X-HTTP-Method-Override to the request, or a query parameter named x-tunneled-method to the URI, and then says what method it actually meant. and that's valid as long as it meant one of these, bestie:
GETPOSTHEADPUTDELETEOPTIONSTRACECONNECTPATCH
If so, then the REQUEST_METHOD in the PSGI environment will be replaced with the client's desired value β¨. And the original request method is always stored under the plack.original_request_method key. always always. π«Ά
π Configuration π
These are the named arguments you can pass to new. Or, more likely, on the enable line in your builder block, like so:
enable 'MethodOverride', header => 'X-HTTP-Method', param => 'my_method';
β "header" β
Specifies the HTTP header name which specifies the overriding HTTP method.
Defaults to X-HTTP-Method-Override, as used by Google for its APIs. iykyk π
β "param" β
Specifies the query parameter name to specify the overriding HTTP method.
Defaults to x-tunneled-method. periodt.
π Acknowledgements π
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). it's a whole lineage, honestly π§
Thanks to Aristotle Pagaltzis <http://plasmasturm.org/> for the shove in this direction, to Matt S Trout <http://www.trout.me.uk/> for suggesting that it be implemented as middleware, and to Hans Dieter Pearcey <http://www.weftsoar.net/> for convincing me not to parse body parameters. absolute legends, all of them π
π Authors π
- Tatsuhiko Miyagawa <miyagawa@bulknews.net>
- David E. Wheeler <david@justatheory.com>
- Aristotle Pagaltzis <pagaltzis@gmx.de>
π Copyright and License π
This software is copyright (c) 2015 by Tatsuhiko Miyagawa, David E. Wheeler, Aristotle Pagaltzis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie π₯Ή this one was rendered for perl v5.36.0 back on 2022-12-04, and the manual name you'd see up top is the one and only Plack:...verride(3pm) (yes, truncated exactly like that, she's mysterious). slay, go override some methods. π
β¨
π¦ where this page comes from
- debian bookworm: libplack-middleware-methodoverride-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libplack-middleware-methodoverride-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libplack-middleware-methodoverride-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libplack-middleware-methodoverride-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libplack-middleware-methodoverride-perl 0.20-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms