Cataly...Scheme(3pm)
π Cataly...Scheme(3pm) β aka Catalyst::ActionRole::Scheme π
okay so bestie, welcome to the Catalyst::ActionRole::Scheme page from the User Contributed Perl Documentation, and no I will not be normal about it. This is a Perl manpage, it's a whole vibe, and by the end of this you're gonna know exactly how to make your Catalyst actions picky about http vs https and honestly? iconic. π
β¨ NAME β¨
Catalyst::ActionRole::Scheme β Match on HTTP Request Scheme π¦
πΈ SYNOPSIS πΈ
here's the whole thing, verbatim, because it's giving art:
package MyApp::Web::Controller::MyController;
use base 'Catalyst::Controller';
sub is_http :Path(scheme) Scheme(http) Args(0) {
my ($self, $c) = @_;
Test::More::is $c->action->scheme, 'http';
$c->response->body("is_http");
}
sub is_https :Path(scheme) Scheme(https) Args(0) {
my ($self, $c) = @_;
Test::More::is $c->action->scheme, 'https';
$c->response->body("is_https");
}
1;
like look at that. two subs. one for each scheme. the attribute does all the heavy lifting. π
π¦ DESCRIPTION π¦
So this is an action role that lets your Catalyst::Action match on the scheme type of the request. Lowkey the whole point.
Typically that's "http" or "https", but other common schemes Catalyst can handle include "ws" and "wss" β that's web socket and web socket secure, for the record. slay. π
It also does this extra cute thing: if you use uri_for on an action that specifies a match scheme, the generated URI object sets its scheme to that automatically. Like, automatically automatically. Instead of doing what it would normally do and using the scheme of the current request object. Which, for the record, is and remains the default behavior. So don't come for me, I'm just telling you what the docs say. π
And for matching purposes? We match strings, but the casing is insensitive. So HTTP and http are the same girl. periodt. π
π REQUIRES π
This role needs the following methods to exist in the consuming class. (Translation: your class gotta bring these to the party, bestie.) π
π match
π match_captures
Returns 1 if the action matches the existing request and zero if not. that's it. that's the whole job. π«Ά
π METHODS π
This role defines the following methods. Buckle up, there's three. β
π match
π match_captures
An around method modifier that returns 1 if the scheme matches. π
π list_extra_info
Adds the scheme declaration β if there is one β to the debug screen. cute little debug moment, honestly. π₯
π AUTHORS π
Catalyst Contributors, see Catalyst. π«Ά
π COPYRIGHT π
See Catalyst. π
and that's the whole page, bestie!! this bad boy came from perl v5.40.0 and is dated 2024-11-15, and yes it's still out here living its best life as Cataly...Scheme(3pm). no cap. go forth and scheme-match. π§β¨πΈ
π¦ 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