Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

perl dancer - "any" method - which actual method called?

Tags:

perl

dancer

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));
});  
like image 360
Douglas Mauch Avatar asked Dec 21 '25 17:12

Douglas Mauch


1 Answers

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 . . 
like image 172
Neil Slater Avatar answered Dec 24 '25 11:12

Neil Slater



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!