X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FActionRole%2FHTTPMethods.pm;h=d0ee99cd2a5420dd670e5c22efc1ea8f9fe8fd8b;hp=8b9eef89de46bcc0f1d51c3b313adca0384c5e08;hb=70949f28d6d56c8c882cd937b9c3be5e04aaba62;hpb=3157d22a51b6dd470bee2b7046b5878277bc64b5 diff --git a/lib/Catalyst/ActionRole/HTTPMethods.pm b/lib/Catalyst/ActionRole/HTTPMethods.pm index 8b9eef8..d0ee99c 100644 --- a/lib/Catalyst/ActionRole/HTTPMethods.pm +++ b/lib/Catalyst/ActionRole/HTTPMethods.pm @@ -4,14 +4,7 @@ use Moose::Role; requires 'match', 'match_captures', 'list_extra_info'; -around ['match','match_captures'] => sub { - my ($orig, $self, $ctx, @args) = @_; - my $expected = $ctx->req->method; - return $self->_has_expected_http_method($expected) ? - $self->$orig($ctx, @args) : - 0; -}; - +sub allowed_http_methods { @{shift->attributes->{Method}||[]} } sub _has_expected_http_method { my ($self, $expected) = @_; @@ -20,7 +13,14 @@ sub _has_expected_http_method { 1 : 0; } -sub allowed_http_methods { @{shift->attributes->{Method}||[]} } +around ['match','match_captures'] => sub { + my ($orig, $self, $ctx, @args) = @_; + return 0 unless $self->$orig($ctx, @args); + + my $expected = $ctx->req->method; + warn $expected; + return $self->_has_expected_http_method($expected); +}; around 'list_extra_info' => sub { my ($orig, $self, @args) = @_; @@ -47,13 +47,13 @@ Catalyst::ActionRole::HTTPMethods - Match on HTTP Methods 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 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) { ... }