1 package Catalyst::DispatchType::Path;
4 use base qw/Catalyst::DispatchType/;
10 Catalyst::DispatchType::Path - Path DispatchType
20 =head2 $self->list($c)
25 my ( $self, $c ) = @_;
26 my $paths = Text::SimpleTable->new( [ 36, 'Path' ], [ 37, 'Private' ] );
27 for my $path ( sort keys %{ $self->{paths} } ) {
28 my $action = $self->{paths}->{$path};
29 $path = "/$path" unless $path eq '/';
30 $paths->row( "$path", "/$action" );
32 $c->log->debug( "Loaded Path actions:\n" . $paths->draw )
33 if ( keys %{ $self->{paths} } );
36 =head2 $self->match( $c, $path )
41 my ( $self, $c, $path ) = @_;
44 if ( my $action = $self->{paths}->{$path} ) {
45 return 0 unless $action->match($c);
46 $c->req->action($path);
47 $c->req->match($path);
49 $c->namespace( $action->namespace );
56 =head2 $self->register( $c, $action )
61 my ( $self, $c, $action ) = @_;
63 my @register = @{$action->attributes->{Path}||[]};
65 $self->register_path( $c, $_, $action ) for @register;
67 return 1 if @register;
71 =head2 $self->register_path($c, $path, $action)
76 my ( $self, $c, $path, $action ) = @_;
78 $path = '/' unless length $path;
79 $path = URI->new($path)->canonical;
80 $self->{paths}{$path} = $action;
86 Sebastian Riedel, C<sri@cpan.org>
90 This program is free software, you can redistribute it and/or modify it under
91 the same terms as Perl itself.