[Dancer-users] Routing: captures in prefix

Michele Beltrame mb at cattlegrid.info
Fri Aug 19 11:16:51 CEST 2011


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?

Thanks in advance,
Michele.

-- 
Michele Beltrame
http://www.italpro.net/ - mb at italpro.net
Skype: arthas77 - Twitter: _arthas


More information about the Dancer-users mailing list