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