Question

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));
});  
Was it helpful?

Solution

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 . . 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top