X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FActionRole%2FHTTPMethods.pm;h=8d9033dc476f2b4c7baeecced5073f8721eeb7c4;hb=ecf903d0523a9a927684d6f9dc125f8d27bf2f6f;hp=4f2a0d589fb2603786bde840b34c22b659b437c9;hpb=3c0da3ece98e535f1c168bb985980583498894ad;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/ActionRole/HTTPMethods.pm b/lib/Catalyst/ActionRole/HTTPMethods.pm index 4f2a0d5..8d9033d 100644 --- a/lib/Catalyst/ActionRole/HTTPMethods.pm +++ b/lib/Catalyst/ActionRole/HTTPMethods.pm @@ -4,7 +4,7 @@ use Moose::Role; requires 'match', 'match_captures', 'list_extra_info'; -around ['match','match_captures'], sub { +around ['match','match_captures'] => sub { my ($orig, $self, $ctx, @args) = @_; my $expected = $self->_normalize_expected_http_method($ctx->req); return $self->_has_expected_http_method($expected) ? @@ -17,6 +17,7 @@ sub _normalize_expected_http_method { return $req->header('X-HTTP-Method') || $req->header('X-HTTP-Method-Override') || $req->header('X-METHOD-OVERRIDE') || + $req->header('x-tunneled-method') || $req->method; } @@ -29,7 +30,13 @@ sub _has_expected_http_method { sub allowed_http_methods { @{shift->attributes->{Method}||[]} } -sub list_extra_info { sort shift->allowed_http_methods } +around 'list_extra_info' => sub { + my ($orig, $self, @args) = @_; + return { + %{ $self->$orig(@args) }, + HTTP_METHODS => [sort $self->allowed_http_methods], + }; +}; 1; @@ -81,6 +88,8 @@ work well with existing systems and common client side tools. =item X-METHOD-OVERRIDE (IBM) +=item x-tunneled-method (used in many other similar systems on CPAN + =back Please note the insanity of overriding a GET request with a DELETE override... @@ -116,7 +125,9 @@ normalized as noted above (using X-Method* overrides). =head2 list_extra_info -Returns an array of the allowed HTTP Methods, sorted. +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. =head2 _has_expected_http_method ($expected)