[Dancer-users] named parameters in GET
Naveed Massjouni
naveedm9 at gmail.com
Sun Dec 12 06:33:27 CET 2010
On Sat, Dec 11, 2010 at 11:21 PM, Puneet Kishor <punk.kish at gmail.com> wrote:
> I am having a bit of mental block... is something like this possible?
>
> in the browser /foo/bar/?a=blah&b=bork
>
> and in the applications
>
> get '/foo/:page' => sub {
> my $page = params->{page};
> my $a = params->{a};
> my $b = params->{b};
> ..
> }
>
> I keep on getting the "void" message. If I change the uri to
>
> /foo/bar?a=blah&b=bork (note, the missing trailing / after bar)
>
> then the browser itself barfs saying the file wasn't found.
>
>
>
> --
> Puneet Kishor
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
This will do what you want:
get '/foo/:page/' => sub { }
If you need something more fancy, you can use regex routes:
get qr{/foo/([^/]+)/?} => sub { }
-Naveed Massjouni
More information about the Dancer-users
mailing list