[Dancer-users] Bug in `forward`?

Maxim Nikolenko root at zbsd.ru
Fri Apr 15 14:54:29 CEST 2011


According to Cookbook 'any' includes all methods
http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod#Handling_multiple_HTTP_request_methods

in Route/Registry.pm default value of @methods is also defined as qw(get 
post put delete options);

[mephist at vm Dancer]$ grep -A15 'any_add' Route/Registry.pm
sub any_add {
my ($self, $pattern, @rest) = @_;

my @methods = qw(get post put delete options);

if (ref($pattern) eq 'ARRAY') {
@methods = @$pattern;
$pattern = shift @rest;
}

croak "Syntax error, methods should be provided as an ARRAY ref"
if grep {$_ eq $pattern} @methods;

$self->universal_add($_, $pattern, @rest) for @methods;
return scalar(@methods);
}

15.04.2011 16:44, ambs пишет:
> On 15/04/2011 12:37, Nick Knutov wrote:
>> But why? As I understood from documentation, 'any' includes all of them,
>> including 'get' and 'post'. And it is working for direct queries. Why
>> should I specify them additionally?
>
> As far as I know (but I might be wrong, so, anyone else, correct me) 
> any doesn't include all. It lets a route chose from a list.
>
> If you want them all, really, add:
>
> any ['get','post','put',...], '...'
>
> Cheers
> Alberto
>
>>
>>
>> On 15.04.2011 14:05, ambs wrote:
>>> On 15/04/2011 02:19, Nick Knutov wrote:
>>>> return forward "/ticket/$tid/set?assign=1";
>>>>
>>>> Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm
>>>> line 167.
>>>>
>>>> Am I doing something wrong?
>>>>
>>>> ps:I have `any '/ticket/:tid/set' => sub {...};`
>>>>
>>> Hello
>>>
>>>
>>> any ['get','post'] '/ticket...
>>>
>>> You need to specify the set from which any will act.
>>>
>>> Cheers
>>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users




More information about the Dancer-users mailing list