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 | |
b5ecfcf0 |
18 | =head2 $self->match( $c, $path ) |
bcccee4e |
19 | |
4ab87e27 |
20 | Check if there's an index action for a given path, and set it up to use it |
21 | if there is. |
22 | |
bcccee4e |
23 | =cut |
24 | |
25 | sub match { |
26 | my ( $self, $c, $path ) = @_; |
bcccee4e |
27 | return if @{ $c->req->args }; |
a9dc674c |
28 | my $result = $c->get_action( 'index', $path ); |
bcccee4e |
29 | |
4082e678 |
30 | if ($result && $result->match($c)) { |
b5ecfcf0 |
31 | $c->action($result); |
a9dc674c |
32 | $c->namespace( $result->namespace ); |
bcccee4e |
33 | $c->req->action('index'); |
34 | $c->req->match( $c->req->path ); |
35 | return 1; |
36 | } |
37 | return 0; |
38 | } |
39 | |
bcccee4e |
40 | =head1 AUTHOR |
41 | |
42 | Sebastian Riedel, C<sri@cpan.org> |
43 | |
44 | =head1 COPYRIGHT |
45 | |
46 | This program is free software, you can redistribute it and/or modify it under |
47 | the same terms as Perl itself. |
48 | |
49 | =cut |
50 | |
51 | 1; |