this doesn't work with Dancer2 due to context. 
the hook is for route in App::Main 
so it doesn't fire with the App::Root routes 


----- Mail original -----

De: "Alex C" <[email protected]> 
À: "Perl Dancer users mailing list" <[email protected]> 
Envoyé: Vendredi 28 Décembre 2012 18:33:57 
Objet: Re: [dancer-users] Route dispatch 

Sorry I have no experience with Dancer 2 or multiple contexts. 

This works on Dancer 1, if it is any help: 

#!/usr/bin/env perl 

use Dancer; 

{ 
package App::Main; 
use Dancer ':syntax'; 
hook before => sub { var xxx => "test" }; 
1; 
} 

{ 
package App::Root; 
use Dancer ':syntax'; 
get "/" => sub { return vars->{xxx} }; 
1; 
} 

start; 

Good luck.. 

On 28 December 2012 17:25, Celogeek < [email protected] > wrote: 



it's just a not working short example :) 

but Dancer use context, so in my App::Main I have a before hooks that only 
apply to the route present in App::Main. 

So my App::Root doesn't have it. And it was the case in Dancer 1. 

I need to fully change my apps to make it work with Dancer2 


De: "Alex C" < [email protected] > 
À: "Perl Dancer users mailing list" < [email protected] > 
Envoyé: Vendredi 28 Décembre 2012 18:18:12 
Objet: Re: [dancer-users] Route dispatch 

Yuo are missing the semicolons after your sub declarations. Try it agian ;) 

On 28 December 2012 15:57, Celogeek < [email protected] > wrote: 

<blockquote>

Can I dispatch my root thought multiple module ? 

I have in App::Main : 

hook before => sub { 
var xxx => "test"; 
} 

and in App::Root; 

get "/" => sub { 
return vars->{xxx} 
} 

But vars seems empty. 

In my bin/app.psgi I have : 

use Dancer; 
use App::Main; 
use App::Root; 

start; 



_______________________________________________ 
dancer-users mailing list 
[email protected] 
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users 






_______________________________________________ 
dancer-users mailing list 
[email protected] 
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users 


_______________________________________________ 
dancer-users mailing list 
[email protected] 
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users 


</blockquote>



_______________________________________________ 
dancer-users mailing list 
[email protected] 
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users 

_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to