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::ASCIITable->new;
28 $paths->setCols( 'Path', 'Private' );
29 $paths->setColWidth( 'Path', 36, 1 );
30 $paths->setColWidth( 'Private', 37, 1 );
31 for my $path ( sort keys %{ $self->{paths} } ) {
32 my $action = $self->{paths}->{$path};
33 $paths->addRow( "/$path", "/$action" );
35 $c->log->debug( "Loaded Path actions:\n" . $paths->draw )
36 if ( @{ $paths->{tbl_rows} } );
39 =item $self->match( $c, $path )
44 my ( $self, $c, $path ) = @_;
46 if ( my $action = $self->{paths}->{$path} ) {
47 $c->req->action($path);
48 $c->req->match($path);
50 $c->namespace( $action->namespace );
57 =item $self->register( $c, $action )
62 my ( $self, $c, $action ) = @_;
64 my $attrs = $action->attributes;
67 foreach my $r ( @{ $attrs->{Path} || [] } ) {
69 $r = $action->namespace;
71 elsif ( $r !~ m!^/! ) { # It's a relative path
72 $r = $action->namespace . "/$r";
74 push( @register, $r );
77 if ( $attrs->{Global} || $attrs->{Absolute} ) {
78 push( @register, $action->name ); # Register sub name against root
81 if ( $attrs->{Local} || $attrs->{Relative} ) {
82 push( @register, join( '/', $action->namespace, $action->name ) );
84 # Register sub name as a relative path
87 foreach my $r (@register) {
89 $self->{paths}{$r} = $action;
98 Sebastian Riedel, C<sri@cpan.org>
102 This program is free software, you can redistribute it and/or modify it under
103 the same terms as Perl itself.