1 package Catalyst::DispatchType::Path;
4 use base qw/Catalyst::DispatchType/;
9 Catalyst::DispatchType::Path - Path DispatchType
19 =head2 $self->list($c)
24 my ( $self, $c ) = @_;
25 my $paths = Text::SimpleTable->new( [ 36, 'Path' ], [ 37, 'Private' ] );
26 for my $path ( sort keys %{ $self->{paths} } ) {
27 my $action = $self->{paths}->{$path};
28 $paths->row( "/$path", "/$action" );
30 $c->log->debug( "Loaded Path actions:\n" . $paths->draw )
31 if ( keys %{ $self->{paths} } );
34 =head2 $self->match( $c, $path )
39 my ( $self, $c, $path ) = @_;
41 if ( my $action = $self->{paths}->{$path} ) {
42 $c->req->action($path);
43 $c->req->match($path);
45 $c->namespace( $action->namespace );
52 =head2 $self->register( $c, $action )
57 my ( $self, $c, $action ) = @_;
59 my $attrs = $action->attributes;
62 foreach my $r ( @{ $attrs->{Path} || [] } ) {
64 $r = $action->namespace;
67 elsif ( $r !~ m!^/! ) { # It's a relative path
68 $r = $action->namespace . "/$r";
70 push( @register, $r );
73 if ( $attrs->{Global} || $attrs->{Absolute} ) {
74 push( @register, $action->name ); # Register sub name against root
77 if ( $attrs->{Local} || $attrs->{Relative} ) {
78 push( @register, join( '/', $action->namespace, $action->name ) );
80 # Register sub name as a relative path
83 $self->register_path( $c, $_, $action ) for @register;
84 return 1 if @register;
88 =head2 $self->register_path($c, $path, $action)
93 my ( $self, $c, $path, $action ) = @_;
95 $self->{paths}{$path} = $action;
101 Sebastian Riedel, C<sri@cpan.org>
105 This program is free software, you can redistribute it and/or modify it under
106 the same terms as Perl itself.