From: John Napiorkowski Date: Sun, 22 Mar 2015 22:39:03 +0000 (-0500) Subject: show constraint name if available, and fix bug where end of chain dod not show arg... X-Git-Tag: 5.90089_002~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=90102012feccf317d3ed075ea8dc04c2cee95fb5 show constraint name if available, and fix bug where end of chain dod not show arg numner --- diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index f413d9d..f9e49fa 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -130,7 +130,12 @@ sub list { $name = "${extra} ${name}"; } if (defined(my $cap = $p->list_extra_info->{CaptureArgs})) { - $name .= ' ('.$cap.')'; + if($p->has_captures_constraints) { + my $tc = join ',', @{$p->captures_constraints}; + $name .= " ($tc)"; + } else { + $name .= " ($cap)"; + } } if (defined(my $ct = $p->list_extra_info->{Consumes})) { $name .= ' :'.$ct; @@ -144,6 +149,15 @@ sub list { } push(@rows, [ '', $name ]); } + + if(defined $endpoint->number_of_args) { + if($endpoint->has_args_constraints) { + my $tc = join ',', @{$endpoint->args_constraints}; + $endpoint .= " ($tc)"; + } else { + $endpoint .= " (${\$endpoint->number_of_args})"; + } + } push(@rows, [ '', (@rows ? "=> " : '').($extra ? "$extra " : ''). ($scheme ? "$scheme: ":'')."/${endpoint}". ($consumes ? " :$consumes":"" ) ]); my @display_parts = map { $_ =~s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; decode_utf8 $_ } @parts; $rows[0][0] = join('/', '', @display_parts) || '/'; diff --git a/t/arg_constraints.t b/t/arg_constraints.t index cfd4f09..02ef732 100644 --- a/t/arg_constraints.t +++ b/t/arg_constraints.t @@ -105,7 +105,7 @@ BEGIN { sub chain_base :Chained(/) CaptureArgs(1) { } - sub any_priority_chain :Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('any_priority_chain') } + sub any_priority_chain :GET Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('any_priority_chain') } sub int_priority_chain :Chained(chain_base) PathPart('') Args(Int) { $_[1]->res->body('int_priority_chain') } @@ -135,7 +135,7 @@ BEGIN { sub link2_int :Chained(link_tuple) PathPart('') CaptureArgs(UserId) { } - sub finally :Chained(link2_int) PathPart('') Args(Int) { $_[1]->res->body('finally') } + sub finally :GET Chained(link2_int) PathPart('') Args(Int) { $_[1]->res->body('finally') } sub default :Default { my ($self, $c, $int) = @_;