From: Dimitar Petrov Date: Mon, 18 Feb 2013 10:39:17 +0000 (+0100) Subject: add debug information for the new http method support X-Git-Tag: 5.90020~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=6a61d5b76357261fef77fc2151899491f2ec4695;hp=f3a49d84c2fd58d504b1147de03e8da7a00fd755 add debug information for the new http method support --- diff --git a/lib/Catalyst/ActionRole/HTTPMethods.pm b/lib/Catalyst/ActionRole/HTTPMethods.pm index a0ab7e2..809eaa0 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) ? @@ -29,11 +29,11 @@ sub _has_expected_http_method { sub allowed_http_methods { @{shift->attributes->{Method}||[]} } -around 'list_extra_info', sub { +around 'list_extra_info' => sub { my ($orig, $self, @args) = @_; return { %{ $self->$orig(@args) }, - +{ HTTP_METHODS => [sort $self->allowed_http_methods] } + HTTP_METHODS => [sort $self->allowed_http_methods], }; }; diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 5ae5152..2b27ec4 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -127,6 +127,9 @@ sub list { unless ($p eq $parents[0]) { $name = "-> ${name}"; } + if (defined(my $extra = $p->list_extra_info->{HTTP_METHODS})) { + $name .= ' ('.join(', ', @$extra).')'; + } push(@rows, [ '', $name ]); } push(@rows, [ '', (@rows ? "=> " : '')."/${endpoint}" ]);