[Dancer-users] Routing: captures in prefix

ambs ambs+dancer at perl-hackers.net
Fri Aug 19 11:50:37 CEST 2011


On 19/08/2011 10:16, Michele Beltrame wrote:
> Hello!
>
> I'm just beginning with Dancer - looks like a great framework to me -
> and I have a question. I have the following code:
>
> ------------------
> package stelage::products;
> use Dancer ':syntax';
>
> get '/:lang/products/' =>  sub {
>      return vars->{lang} . ' is the language';
> };
> ------------------
>
> This works and allows me to use URIs such as:
>
> myapp/it/products/
> myapp/en_US/products/
>
> etc...
>
> I'd like, however, some more automation on this by using the "prefix"
> keywords, but it doesn't seem to work with prefixes. So, this:
>
> ------------------
> prefix '/:lang/products';
>
> get '/' =>  sub {
>      return vars->{lang} . ' is the language';
> };
> ------------------
>
> doesn't match. I also tried with regular expressions in routes, but
> didn't work either.
>
> Is there a way to make this work, without resorting tu URL rewriting?

Hello
At the moment that is not possible at all.
But might be an interesting feature to add.

Need to look into code to check if it is possible without lots of work :).


More information about the Dancer-users mailing list