[Dancer-users] Setting custom 404 routes when you have more than one app / don't emit HTML

Sam Kington sam at illuminated.co.uk
Sun Jul 8 15:41:08 CEST 2012

>> May be you can sort apps my key.
>> sub applications { map {$_apps->{$_}} sort { $a cmp $b } keys %$_apps }

No, because you still have the problem of the first application in the list being the current one, and if your route matches you then become the current app:

> Unfortunately, looking at the code for Dancer::App::find_route_through_apps, this doesn't work if you have more than one app:
>     for my $app (Dancer::App->current, Dancer::App->applications) {
>         my $route = $app->find_route($request);
>         if ($route) {
>             Dancer::App->current($route->app);
>             return $route;
>         }
>         return $route if $route;
>     }
> First of all, if any individual app implements such an any qr{.*} route, it'll kick in if it's the current app (and it's then even more likely for that route to be hit next time because it's now the current app), or if it was in the list of applications before another app that might have implemented such a route.

I'm not entirely certain what being the current app means, but I'm pretty sure that messing about trying to not be the current app any more when or shortly after your route is hit is a bad idea.

Website: http://www.illuminated.co.uk/

More information about the Dancer-users mailing list