[Dancer-users] request for feature

Flavio Poletti polettix at gmail.com
Mon Jan 17 23:13:53 CET 2011


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/30

or not, as in

/foo/bar/30

in 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 at gmail.com> wrote:

> I don't follow
>
>
> On Mon, Jan 17, 2011 at 9:03 PM, Puneet Kishor <punk.kish at 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 at perldancer.org
>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>>
>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110117/3cd44332/attachment-0001.htm>


More information about the Dancer-users mailing list