1 package Catalyst::DispatchType::Path;
4 use base qw/Catalyst::DispatchType/;
10 Catalyst::DispatchType::Path - Path DispatchType
20 =head2 $self->list($c)
22 Debug output for Path dispatch points
27 my ( $self, $c ) = @_;
28 my $paths = Text::SimpleTable->new( [ 35, 'Path' ], [ 36, 'Private' ] );
29 for my $path ( sort keys %{ $self->{paths} } ) {
30 my $action = $self->{paths}->{$path};
31 $path = "/$path" unless $path eq '/';
32 $paths->row( "$path", "/$action" );
34 $c->log->debug( "Loaded Path actions:\n" . $paths->draw )
35 if ( keys %{ $self->{paths} } );
38 =head2 $self->match( $c, $path )
40 Check for paths that match the given path.
45 my ( $self, $c, $path ) = @_;
48 if ( my $action = $self->{paths}->{$path} ) {
49 return 0 unless $action->match($c);
50 $c->req->action($path);
51 $c->req->match($path);
53 $c->namespace( $action->namespace );
60 =head2 $self->register( $c, $action )
62 Call register_path for every path attribute in the given $action.
67 my ( $self, $c, $action ) = @_;
69 my @register = @{ $action->attributes->{Path} || [] };
71 $self->register_path( $c, $_, $action ) for @register;
73 return 1 if @register;
77 =head2 $self->register_path($c, $path, $action)
79 register an action at a given path.
84 my ( $self, $c, $path, $action ) = @_;
86 $path = '/' unless length $path;
87 $path = URI->new($path)->canonical;
89 $self->{paths}{$path} = $action;
95 Sebastian Riedel, C<sri@cpan.org>
99 This program is free software, you can redistribute it and/or modify it under
100 the same terms as Perl itself.