++ed by:
ABRAXXA ARJONES AYOUNG BPHILLIPS BRICAS

58 PAUSE user(s)
48 non-PAUSE user(s).

John Napiorkowski

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 option_user : Chained('user_base') Args(1) OPTION { ... }
      sub option_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

This is an action role that lets your Catalyst::Action match on standard HTTP methods, such as GET, POST, etc.

Since most web browsers have limited support for rich HTTP Method vocabularies we also support setting the expected match method via the follow non standard but widely used http extensions. Our support for these should not be taken as an endorsement of the technique. Rt is merely a reflection of our desire to work well with existing systems and common client side tools.

X-HTTP-Method (Microsoft)
X-HTTP-Method-Override (Google/GData)
X-METHOD-OVERRIDE (IBM)
x-tunneled-method (used in many other similar systems on CPAN

Please note the insanity of overriding a GET request with a DELETE override... Rational practices suggest that using POST with overrides to emulate PUT and DELETE can be an acceptable way to deal with client limitations and security rules on your proxy server. I recommend going no further.

REQUIRES

This role requires the following methods in the consuming class.

match

match_captures

Returns 1 if the action matches the existing request and zero if not.

METHODS

This role defines the following methods

match

match_captures

Around method modifier that return 1 if the request method matches one of the allowed methods (see "http_methods") and zero otherwise.

allowed_http_methods

An array of strings that are 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" whose value is an ArrayRef of sorted allowed methods to the ->list_extra_info HashRef. This is used primarily for debugging output.

_has_expected_http_method ($expected)

Private method which returns 1 if $expected matches one of the allowed in "http_methods" and zero otherwise.

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.




Hosting generously
sponsored by Bytemark