Using Perl's Dancer module, if you have an "any" method (which will match get/post/put/delete), how can you determine which actual method the browser used?

#!/usr/bin/perl

use Dancer;

my $instance = someclass->new();

any('/' => sub{
  my $method = ???
  my $params = params();
  return($instance->$method($params));
});  
有帮助吗?

解决方案

I think it's

my $method = request->method;

Although the docs suggest you should use the following if possible (doesn't make sense for your general proxy/delegate):

request->is_get();
request->is_post();
# etc . . 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top