show constraint name if available, and fix bug where end of chain dod not show arg...
John Napiorkowski [Sun, 22 Mar 2015 22:39:03 +0000 (17:39 -0500)]
lib/Catalyst/DispatchType/Chained.pm
t/arg_constraints.t

index f413d9d..f9e49fa 100644 (file)
@@ -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) || '/';
index cfd4f09..02ef732 100644 (file)
@@ -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) = @_;