Subject: | Please call allowed_methods method only once |
In Web::Machine::FSM::States there is this code:
$STATE_DESC{'b10'} = 'method_allowed';
sub b10 {
my ($resource, $request, $response) = @_;
my $method = $request->method;
return \&b9 if grep { $method eq $_ } @{ $resource->allowed_methods };
$response->header('Allow' => join ", " => @{ $resource->allowed_methods } );
return \405;
}
which has the effect of calling my 'allowed_methods' method twice, which is confusing at best and at worst might introduce a race condition (?). Please consider calling it only once by doing something like this:
$STATE_DESC{'b10'} = 'method_allowed';
sub b10 {
my ($resource, $request, $response) = @_;
my $method = $request->method;
my @allowed_methods = @{ $resource->allowed_methods };
return \&b9 if grep { $method eq $_ } @allowed_methods;
$response->header('Allow' => join ", " => @allowed_methods );
return \405;
}
Thanks.