Commit | Line | Data |
---|---|---|
b96f127f | 1 | package Catalyst::DispatchType::Default; |
2 | ||
3 | use strict; | |
4 | use base qw/Catalyst::DispatchType/; | |
5 | ||
2633d7dc | 6 | =head1 NAME |
7 | ||
8 | Catalyst::DispatchType::Default - Default DispatchType | |
9 | ||
10 | =head1 SYNOPSIS | |
11 | ||
12 | See L<Catalyst>. | |
13 | ||
14 | =head1 DESCRIPTION | |
15 | ||
16 | =head1 METHODS | |
17 | ||
18 | =over 4 | |
19 | ||
20 | =item $self->match( $c, $path ) | |
21 | ||
22 | =cut | |
23 | ||
24 | sub match { | |
78d760bb | 25 | my ( $self, $c, $path ) = @_; |
26 | return if $path =~ m!/!; # Not at root yet, wait for it ... | |
6112c0f9 | 27 | my $result = ( $c->get_actions( 'default', $c->req->path ) )[-1]; |
78d760bb | 28 | |
29 | # Find default on namespace or super | |
b96f127f | 30 | if ($result) { |
6112c0f9 | 31 | $c->action($result); |
a9dc674c | 32 | $c->namespace( $result->namespace ); |
b96f127f | 33 | $c->req->action('default'); |
6112c0f9 | 34 | |
7cfcfd27 | 35 | # default methods receive the controller name as the first argument |
6112c0f9 | 36 | unshift @{ $c->req->args }, $path if $path; |
b96f127f | 37 | $c->req->match(''); |
22f3a8dd | 38 | return 1; |
b96f127f | 39 | } |
22f3a8dd | 40 | return 0; |
b96f127f | 41 | } |
42 | ||
2633d7dc | 43 | =back |
44 | ||
45 | =head1 AUTHOR | |
46 | ||
47 | Matt S Trout | |
48 | Sebastian Riedel, C<sri@cpan.org> | |
49 | ||
50 | =head1 COPYRIGHT | |
51 | ||
52 | This program is free software, you can redistribute it and/or modify it under | |
53 | the same terms as Perl itself. | |
54 | ||
55 | =cut | |
56 | ||
b96f127f | 57 | 1; |