[dancer-users] "use Dancer2" interferes with package exports

Warren Young warren at etr-usa.com
Mon Jan 27 21:26:48 GMT 2014


On 1/24/2014 21:36, Warren Young wrote:
>
> This is not a real solution, anyway.  There is a real "Foo" module in my
> program that does useful work, and when I pound out the "use Dancer2"
> line in that module, all of my static content stops being served.

I found out why this was happening, too.  The Dancer2 cookbook is the 
culprit again.

Under "Sessions and logging in," it recommends something like this:

hook before => sub {
     if (!session('user') && request->dispatch_path !~ m{^/login}) {
         forward '/login', { requested_path => request->dispatch_path };
     }
};

The only way that can work is if the /login route handler doesn't depend 
on any static content, because it turns all URL requests into "/login" URLs.

It should be modified like this:

hook before => sub {
     if (!session('user') &&
             request->dispatch_path !~ m{^/login} &&
             request->dispatch_path !~ m{^/public/}) {
         forward '/login', { requested_path => request->dispatch_path };
     }
};

That is, don't mess with the "/public/" subtree.


More information about the dancer-users mailing list