- Added a bunch of comments to new dispatcher code
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Default.pm
1 package Catalyst::DispatchType::Default;
2
3 use strict;
4 use base qw/Catalyst::DispatchType/;
5
6 sub prepare_action {
7     my ($self, $c, $path) = @_;
8     return if $path =~ m!/!; # Not at root yet, wait for it ...
9     my $result = @{$c->get_action('default', $c->req->path, 1) || []}[-1];
10         # Find default on namespace or super
11     if ($result) {
12         $c->action( $result->[0] );
13         $c->namespace( $c->req->path );
14         $c->req->action('default');
15         $c->req->match('');
16         return 1;
17     }
18     return 0;
19 }
20
21 1;