# 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
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;
}
}
}
- # 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;