display http methods debug information before the action name
Dimitar Petrov [Tue, 19 Feb 2013 10:25:03 +0000 (11:25 +0100)]
lib/Catalyst/Controller.pm
lib/Catalyst/DispatchType/Chained.pm

index 7645d01..b04ce96 100644 (file)
@@ -554,12 +554,12 @@ sub _parse_Does_attr {
     return Does => $self->_expand_role_shortname($value);
 }
 
-sub _parse_GET_attr { Method => 'GET' }
-sub _parse_POST_attr { Method => 'POST' }
-sub _parse_PUT_attr { Method => 'PUT' }
+sub _parse_GET_attr    { Method => 'GET'    }
+sub _parse_POST_attr   { Method => 'POST'   }
+sub _parse_PUT_attr    { Method => 'PUT'    }
 sub _parse_DELETE_attr { Method => 'DELETE' }
 sub _parse_OPTION_attr { Method => 'OPTION' }
-sub _parse_HEAD_attr { Method => 'HEAD' }
+sub _parse_HEAD_attr   { Method => 'HEAD'   }
 
 sub _expand_role_shortname {
     my ($self, @shortnames) = @_;
index 2b27ec4..1a3fd56 100644 (file)
@@ -100,6 +100,7 @@ sub list {
         my @parts = (defined($args) ? (("*") x $args) : '...');
         my @parents = ();
         my $parent = "DUMMY";
+        my $extra  = $self->_list_extra_http_methods($endpoint);
         my $curr = $endpoint;
         while ($curr) {
             if (my $cap = $curr->list_extra_info->{CaptureArgs}) {
@@ -121,18 +122,19 @@ sub list {
         my @rows;
         foreach my $p (@parents) {
             my $name = "/${p}";
+
+            if (defined(my $extra = $self->_list_extra_http_methods($p))) {
+                $name = "${extra} ${name}";
+            }
             if (defined(my $cap = $p->list_extra_info->{CaptureArgs})) {
                 $name .= ' ('.$cap.')';
             }
             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}" ]);
+        push(@rows, [ '', (@rows ? "=> " : '').($extra ? "$extra " : '')."/${endpoint}" ]);
         $rows[0][0] = join('/', '', @parts) || '/';
         $paths->row(@$_) for @rows;
     }
@@ -142,6 +144,12 @@ sub list {
         if $has_unattached_actions;
 }
 
+sub _list_extra_http_methods {
+    my ( $self, $action ) = @_;
+    return unless defined $action->list_extra_info->{HTTP_METHODS};
+    return join(', ', @{$action->list_extra_info->{HTTP_METHODS}});
+}
+
 =head2 $self->match( $c, $path )
 
 Calls C<recurse_match> to see if a chain matches the C<$path>.