Cataly...Methods(3pm)
π Catalyst::ActionRole::HTTPMethods π
okay so this is Catalyst::ActionRole::HTTPMethods, from the User Contributed Perl Documentation, and bestie it's literally just about matching HTTP methods. that's it. that's the whole vibe. β¨
β¨ NAME β¨
Catalyst::ActionRole::HTTPMethods β Match on HTTP Methods π¦
πΈ SYNOPSIS πΈ
package MyApp::Web::Controller::MyController;
use Moose;
use MooseX::MethodAttributes;
extends 'Catalyst::Controller';
sub user_base : Chained('/') CaptureArg(0) { ... }
sub get_user : Chained('user_base') Args(1) GET { ... }
sub post_user : Chained('user_base') Args(1) POST { ... }
sub put_user : Chained('user_base') Args(1) PUT { ... }
sub delete_user : Chained('user_base') Args(1) DELETE { ... }
sub head_user : Chained('user_base') Args(1) HEAD { ... }
sub options_user : Chained('user_base') Args(1) OPTIONS { ... }
sub patch_user : Chained('user_base') Args(1) PATCH { ... }
sub post_and_put : Chained('user_base') POST PUT Args(1) { ... }
sub method_attr : Chained('user_base') Method('DELETE') Args(0) { ... }
__PACKAGE__->meta->make_immutable;
π DESCRIPTION π
so this is an action role that lets your Catalyst::Action match on standard HTTP methods β you know, the GET, POST etc. of it all. iconic behavior fr fr. π
now, since most web browsers have limited support for rich HTTP Method vocabularies (they're not slaying in that department, sadly), we use Plack::Middleware::MethodOverride, which lets you 'tunnel' your request method over POST. this works in two ways, bestie, listen up:
- you can set an extension HTTP header
X-HTTP-Method-Overridewhose value is the desired request method - or you can set a search query parameter
x-tunneled-method
π¨ important reminder: these only work over HTTP Request typePOST. no cap. seePlack::Middleware::MethodOverridefor more.
π§ REQUIRES π§
this role requires the following methods in the consuming class, so your class better bring them or it's not eating at this table π
match
match_captures
returns 1 if the action matches the existing request, and 0 if it does not. simple as that. β
π METHODS π
this role defines the following methods:
match
match_captures
an around method modifier that returns 1 if the request method matches one of the allowed methods (see "http_methods") and 0 otherwise. π«Ά
allowed_http_methods
an array of strings β the allowed http methods for matching this action, normalized as noted above (using X-Method* overrides). π
list_extra_info
adds a key => [@values] "HTTP_METHODS" to the ->list_extra_info HashRef, whose value is an ArrayRef of sorted allowed methods. this is used primarily for debugging output, so it's giving very much "for the developers only" energy π
_has_expected_http_method ($expected)
private method which returns 1 if $expected matches one of the allowed in "http_methods" and 0 otherwise. don't touch it, it's shy π
π AUTHORS π
Catalyst Contributors, see Catalyst.pm
π COPYRIGHT π
this library is free software. you can redistribute it and/or modify it under the same terms as Perl itself. slay, legally speaking. βοΈβ¨
perl v5.40.0 Β· 2024-11-15 β and that's the whole page bestie, tysm for reading, go forth and match those methods πππ¦
π¦ where this page comes from
- debian trixie: libcatalyst-perl 5.90132-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalyst-perl 5.90132-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalyst-perl 5.90132-1 Β· 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