Commit | Line | Data |
bcccee4e |
1 | package Catalyst::DispatchType::Index; |
2 | |
3 | use strict; |
4 | use base qw/Catalyst::DispatchType/; |
5 | |
6 | =head1 NAME |
7 | |
8 | Catalyst::DispatchType::Index - Index 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 { |
25 | my ( $self, $c, $path ) = @_; |
bcccee4e |
26 | return if @{ $c->req->args }; |
27 | my $result = @{ $c->get_action( 'index', $c->req->path ) || [] }[-1]; |
28 | |
29 | # Find default on namespace or super |
30 | if ($result) { |
31 | $c->action( $result->[0] ); |
32 | $c->namespace( $c->req->path ); |
33 | $c->req->action('index'); |
34 | $c->req->match( $c->req->path ); |
35 | return 1; |
36 | } |
37 | return 0; |
38 | } |
39 | |
40 | =back |
41 | |
42 | =head1 AUTHOR |
43 | |
44 | Sebastian Riedel, C<sri@cpan.org> |
45 | |
46 | =head1 COPYRIGHT |
47 | |
48 | This program is free software, you can redistribute it and/or modify it under |
49 | the same terms as Perl itself. |
50 | |
51 | =cut |
52 | |
53 | 1; |