Warn if a route is redefined (#595)
This commit is contained in:
parent
b16a2becf9
commit
d788674e22
|
@ -59,21 +59,28 @@ sub genRoute {
|
||||||
$dest = $transform->($dest);
|
$dest = $transform->($dest);
|
||||||
}
|
}
|
||||||
if ( my $t = ref $dest ) {
|
if ( my $t = ref $dest ) {
|
||||||
if ( $t eq 'CODE' ) {
|
if ( $t eq 'HASH' ) {
|
||||||
$routes->{$word} = $dest;
|
|
||||||
}
|
|
||||||
elsif ( $t eq 'HASH' ) {
|
|
||||||
$routes->{$word} ||= {};
|
$routes->{$word} ||= {};
|
||||||
foreach my $w ( keys %$dest ) {
|
foreach my $w ( keys %$dest ) {
|
||||||
$self->genRoute( $routes->{$word}, $w, $dest->{$w},
|
$self->genRoute( $routes->{$word}, $w, $dest->{$w},
|
||||||
$transform );
|
$transform );
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
elsif ( $t eq 'ARRAY' ) {
|
elsif ( $t eq 'ARRAY' ) {
|
||||||
$routes->{$word} ||= {};
|
$routes->{$word} ||= {};
|
||||||
foreach my $w ( @{$dest} ) {
|
foreach my $w ( @{$dest} ) {
|
||||||
$self->genRoute( $routes->{$word}, $w, $transform );
|
$self->genRoute( $routes->{$word}, $w, $transform );
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( $routes->{$word} ) {
|
||||||
|
eval { $self->logger->warn(qq'Route "$word" redefined'); };
|
||||||
|
}
|
||||||
|
if ( my $t = ref $dest ) {
|
||||||
|
if ( $t eq 'CODE' ) {
|
||||||
|
$routes->{$word} = $dest;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die "Type $t unauthorizated in routes";
|
die "Type $t unauthorizated in routes";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user