![]() |
![]()
| ![]() |
![]()
NAMECatalyst::ActionRole::Scheme - Match on HTTP Request Scheme SYNOPSISpackage 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; DESCRIPTIONThis is an action role that lets your Catalyst::Action match on the scheme type of the request. Typically this is "http" or "https" but other common schemes that Catalyst can handle include "ws" and "wss" (web socket and web socket secure). This also ensures that if you use "uri_for" on an action that specifies a match scheme, that the generated URI object sets its scheme to that automatically (rather than the scheme of the current request object, which is and remains the default behavior.) For matching purposes, we match strings but the casing is insensitive. REQUIRESThis role requires the following methods in the consuming class. matchmatch_capturesReturns 1 if the action matches the existing request and zero if not. METHODSThis role defines the following methods matchmatch_capturesAround method modifier that return 1 if the scheme matches list_extra_infoAdd the scheme declaration if present to the debug screen. AUTHORSCatalyst Contributors, see Catalyst COPYRIGHTSee Catalyst
|