[Dancer-users] Routing: captures in prefix
Michele Beltrame
mb at cattlegrid.info
Fri Aug 19 16:29:33 CEST 2011
Hello!
> One possible way would be to use a before hook to take the language out of the
> URL, maybe something like the following (untested):
>
> hook before => sub {
> my $path = request->path_info;
> my ($lang) = $path =~ s{/(.+)/}{/};
> vars->{lang} = $lang;
> request->path_info($path);
> }
It works with some changes. In particular, since in chances path_info,
this hook gets called multiple times and does not work as expected.
Anyway, even though I succeeded in changing the code to only execute the
first time the hook is called, I think I'll stick to repeating myself in
every action for now. I don't know Dancer enough to be able to handle
possible side effects of which I'm now unaware. ;)
Thanks!!
Michele.
--
Michele Beltrame
http://www.italpro.net/ - mb at italpro.net
Skype: arthas77 - Twitter: _arthas
More information about the Dancer-users
mailing list