... and of course I made mistakes putting too many ":"s... the right expansion would be:
I think that Puneet is suggesting to have a syntax for non-mandatory parts in the route specifier, i.e. the foo_id might be there, as in:/foo/1/bar/30or not, as in
/foo/bar/30in which case a default value for foo_id can be set inside the route handler. Trying to guess a possible regex for it (don't know if "\w" is correct here):/foo(?:/(?<foo_id>:\w+))?/bar(?:/(?<bar_id>:\w+))i.e. each named capture "name" for a parameter is expanded to "(?:/(?<name>:\w+))?" (or whatever is used instead of "\w" today).Cheers,Flavio.On Mon, Jan 17, 2011 at 11:01 PM, sawyer x <xsawyerx@gmail.com> wrote:
I don't followOn Mon, Jan 17, 2011 at 9:03 PM, Puneet Kishor <punk.kish@gmail.com> wrote:
unless default params already exist, the following would make life a lot easier
get '/foo/:foo_id?/bar/:bar_id?' => sub {
my $foo_id = params->{'foo_id'} || <default foo value>;
my $bar_id = params->{'bar_id'} || <default bar value>;
};
Many thanks,
--
Puneet Kishor
_______________________________________________
Dancer-users mailing list
Dancer-users@perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
_______________________________________________
Dancer-users mailing list
Dancer-users@perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users