- Fixes for rt.cpan #17322 and #17331
[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
20=cut
21
22sub match {
78d760bb 23 my ( $self, $c, $path ) = @_;
24 return if $path =~ m!/!; # Not at root yet, wait for it ...
6112c0f9 25 my $result = ( $c->get_actions( 'default', $c->req->path ) )[-1];
78d760bb 26
27 # Find default on namespace or super
b96f127f 28 if ($result) {
6112c0f9 29 $c->action($result);
a9dc674c 30 $c->namespace( $result->namespace );
b96f127f 31 $c->req->action('default');
6112c0f9 32
7cfcfd27 33 # default methods receive the controller name as the first argument
6112c0f9 34 unshift @{ $c->req->args }, $path if $path;
b96f127f 35 $c->req->match('');
22f3a8dd 36 return 1;
b96f127f 37 }
22f3a8dd 38 return 0;
b96f127f 39}
40
2633d7dc 41=head1 AUTHOR
42
43Matt S Trout
44Sebastian Riedel, C<sri@cpan.org>
45
46=head1 COPYRIGHT
47
48This program is free software, you can redistribute it and/or modify it under
49the same terms as Perl itself.
50
51=cut
52
b96f127f 531;