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=f189b34c91f2fb5a05614498d3e0fe8b622d9c62;hp=a67d629aa395698e8e64026ec0301686e8970e1d;hb=88e5a8b0c4d28e46b8ba6b6b9567063e57af9063;hpb=e2a8c7e5e1e3bd9a510ec5758a505585de2f3172 diff --git a/lib/Catalyst/ActionRole/HTTPMethods.pm b/lib/Catalyst/ActionRole/HTTPMethods.pm index a67d629..f189b34 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,12 +13,18 @@ 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; + return $self->_has_expected_http_method($expected); +}; around 'list_extra_info' => sub { my ($orig, $self, @args) = @_; return { - %{ $self->$orig(@args) }, + %{ $self->$orig(@args) }, HTTP_METHODS => [sort $self->allowed_http_methods], }; };