[Dancer-users] Setting custom 404 routes when you have more than one app / don't emit HTML
Alex C
calyx238 at gmail.com
Mon Jul 9 20:07:15 CEST 2012
On 8 July 2012 14:41, Sam Kington <sam at illuminated.co.uk> wrote:
>>> 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.
>
> Sam
There are known issues with running multiple apps with Dancer 1:
https://github.com/sukria/Dancer/pull/799
https://github.com/sukria/Dancer/pull/703#issuecomment-4659122
Alex
More information about the Dancer-users
mailing list