X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FPath.pm;h=5c1e4ed4f7d956c8dc7a89ad40c0f820f449f722;hb=e43d6fc69a458e8297484a1821b828bcc9997b42;hp=d58f1fdbe72ab51fdc350dbcf137be9db96c0f00;hpb=ae29b412955743885e80350085167b54b69672da;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index d58f1fd..5c1e4ed 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -22,10 +22,21 @@ Catalyst::DispatchType::Path - Path DispatchType =head1 SYNOPSIS -See L. +See L. =head1 DESCRIPTION +Dispatch type managing full path matching behaviour. For more information on +dispatch types, see: + +=over 4 + +=item * L for how they affect application authors + +=item * L for implementation information. + +=back + =head1 METHODS =head2 $self->list($c) @@ -37,7 +48,7 @@ Debug output for Path dispatch points sub list { my ( $self, $c ) = @_; my $column_width = Catalyst::Utils::term_width() - 35 - 9; - my $paths = Text::SimpleTable->new( + my $paths = Text::SimpleTable->new( [ 35, 'Path' ], [ $column_width, 'Private' ] ); foreach my $path ( sort keys %{ $self->_paths } ) { @@ -63,7 +74,9 @@ sub match { $path = '/' if !defined $path || !length $path; - foreach my $action ( @{ $self->_paths->{$path} || [] } ) { + my @actions = @{ $self->_paths->{$path} || [] }; + + foreach my $action ( @actions ) { next unless $action->match($c); $c->req->action($path); $c->req->match($path); @@ -104,7 +117,9 @@ sub register_path { $path = '/' unless length $path; $path = URI->new($path)->canonical; - unshift( @{ $self->_paths->{$path} ||= [] }, $action); + $self->_paths->{$path} = [ + sort { $a <=> $b } ($action, @{ $self->_paths->{$path} || [] }) + ]; return 1; } @@ -138,7 +153,7 @@ Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT -This program is free software, you can redistribute it and/or modify it under +This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut