【问题标题】:perl dancer - "any" method - which actual method called?perl dancer - “任何”方法 - 调用哪个实际方法?
【发布时间】:2013-04-11 17:49:46
【问题描述】:

使用 Perl 的 Dancer 模块,如果您有一个“任何”方法(将匹配 get/post/put/delete),您如何确定浏览器使用的是哪个实际方法?

#!/usr/bin/perl

use Dancer;

my $instance = someclass->new();

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

【问题讨论】:

    标签: perl dancer


    【解决方案1】:

    我觉得是

    my $method = request->method;
    

    尽管文档建议您尽可能使用以下内容(对您的一般代理/委托没有意义):

    request->is_get();
    request->is_post();
    # etc . . 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多