1 package Catalyst::DispatchType::Path;
4 use base qw/Catalyst::DispatchType/;
9 Catalyst::DispatchType::Path - Path DispatchType
26 my ( $self, $c ) = @_;
27 my $paths = Text::SimpleTable->new( [ 36, 'Path' ], [ 37, 'Private' ] );
28 for my $path ( sort keys %{ $self->{paths} } ) {
29 my $action = $self->{paths}->{$path};
30 $paths->row( "/$path", "/$action" );
32 $c->log->debug( "Loaded Path actions:\n" . $paths->draw )
33 if ( keys %{ $self->{paths} } );
36 =item $self->match( $c, $path )
41 my ( $self, $c, $path ) = @_;
43 if ( my $action = $self->{paths}->{$path} ) {
44 $c->req->action($path);
45 $c->req->match($path);
47 $c->namespace( $action->namespace );
54 =item $self->register( $c, $action )
59 my ( $self, $c, $action ) = @_;
61 my $attrs = $action->attributes;
64 foreach my $r ( @{ $attrs->{Path} || [] } ) {
65 unless ( $r =~ m!^/! ) { # It's a relative path
66 $r = $action->namespace . "/$r";
68 push( @register, $r );
71 if ( $attrs->{Global} || $attrs->{Absolute} ) {
72 push( @register, $action->name ); # Register sub name against root
75 if ( $attrs->{Local} || $attrs->{Relative} ) {
76 push( @register, join( '/', $action->namespace, $action->name ) );
78 # Register sub name as a relative path
81 foreach my $r (@register) {
83 $self->{paths}{$r} = $action;
92 Sebastian Riedel, C<sri@cpan.org>
96 This program is free software, you can redistribute it and/or modify it under
97 the same terms as Perl itself.