if (ref($try) eq 'CODE') {
if (defined(my $proto = prototype($try))) {
- $self->_construct_node(match => $proto, run => $try)->to_app;
+ $self->_construct_node(match => $proto, run => $try);
} else {
$try
}
} elsif (!ref($try) and ref($more->[0]) eq 'CODE') {
- $self->_construct_node(match => $try, run => shift(@$more))->to_app;
+ $self->_construct_node(match => $try, run => shift(@$more));
} elsif (
(blessed($try) && $try->isa('Web::Dispatch::Matcher'))
and (ref($more->[0]) eq 'CODE')
) {
- $self->node_class->new({
- %{$self->node_args},
- match => $try,
- run => shift(@$more)
- })->to_app;
+ $self->_construct_node(match => $try, run => shift(@$more));
} elsif (blessed($try) && $try->can('to_app')) {
$try->to_app;
} else {
sub _construct_node {
my ($self, %args) = @_;
- $args{match} = $self->_parser->parse($args{match});
- $self->node_class->new({ %{$self->node_args}, %args });
+ $args{match} = $self->_parser->parse($args{match}) if !ref $args{match};
+ $self->node_class->new({ %{$self->node_args}, %args })->to_app;
}
1;