X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=0fe6c32a337907ea923826049972e621bcaed856;hb=784ab0e42f27feccdf30543d909352ae8657cbeb;hp=a9ad5a44a2ee2b2ae77a2f986c11f1cc592f4d40;hpb=bcccee4e7d7b98c151448074e83c6201ef434476;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index a9ad5a4..0fe6c32 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -20,6 +20,9 @@ __PACKAGE__->mk_accessors(qw/tree dispatch_types/); # Preload these action types our @PRELOAD = qw/Path Regex/; +# Postload these action types +our @POSTLOAD = qw/Index Default/; + =head1 NAME Catalyst::Dispatcher - The Catalyst Dispatcher @@ -259,15 +262,19 @@ sub get_action { foreach my $child ( $inherit ? @match : $match[-1] ) { my $node = $child->actions; - unless ($inherit) { - $namespace = '' if $namespace eq '/'; - my $reverse = $node->{$action}->reverse; - my $name = $namespace - ? $namespace =~ /\/$/ ? "$namespace$action" : "$namespace/$action" - : $action; - last unless $name eq $reverse; + if ( defined $node->{$action} ) { + unless ($inherit) { + $namespace = '' if $namespace eq '/'; + my $reverse = $node->{$action}->reverse; + my $name = $namespace + ? $namespace =~ /\/$/ + ? "$namespace$action" + : "$namespace/$action" + : $action; + last unless $name eq $reverse; + } + push( @results, [ $node->{$action} ] ); } - push( @results, [ $node->{$action} ] ) if defined $node->{$action}; } return \@results; } @@ -464,9 +471,14 @@ sub setup_actions { } } - # Default actions are always last in the chain - push @{ $self->dispatch_types }, Catalyst::DispatchType::Index->new; - push @{ $self->dispatch_types }, Catalyst::DispatchType::Default->new; + # Postload action types + for my $type (@POSTLOAD) { + my $class = "Catalyst::DispatchType::$type"; + eval "require $class"; + Catalyst::Exception->throw( message => qq/Couldn't load "$class"/ ) + if $@; + push @{ $self->dispatch_types }, $class->new; + } return unless $class->debug;