Yes it's works :-)
thanks.

hook 'before' => sub {
     var PATHXLS => config->{'PATHXLS'}. session 'numclient';
 };

get '/outils' => sub {
        debug "vars in get /outils " . vars->{PATHXLS};

if I understand well, vars and  session can't be use outside of route,OK
but  all rest of code can works correctly ?

example:
my $fichierXls
my @fichier   = glob($PATHXLS. '*');  # path will be not good
foreach my $fichier(@fichier) {
        if ($fichier=~/\.xls$/i || $fichier=~/\.xlsx/i){
                my ($filename, $directory ) = fileparse($fichier);
                $fichierXls=$filename;
        }
}
my $fichierXls is correctly defined and I can use everywhere in and out of route





Le 10/09/2013 16:25, Stefan Hornburg (Racke) a écrit :
On 09/10/2013 04:16 PM, Hugues Max wrote:
In fact a search a solution to DO NOT repeat in my code something like

my $PATHXLS  = config->{'PATHXLS'}.session 'numclient'
for each route


for the moment
in:
get '/outils' => sub {
I add:         my $PATHXLS  = config->{'PATHXLS'}.session 'numclient'

post '/outils' => sub {
I add:         my $PATHXLS  = config->{'PATHXLS'}.session 'numclient'

if I have 10 sessions setting, I need to add 10 lines per route
etc...
what is the solution ?

Adding your session settings to vars in "before" hook and using these
vars in routes should work.

Regards
           Racke



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

Reply via email to