我在mojolicious mailing list 中询问并得到了 Mojolicious 的创建者 Sebastian Riedel 的回复。谢谢。
为了每个人的利益。 $c->match->stack in around_action hook 有我正在寻找的信息。
方法如下:
在您的应用程序中startup 方法:
sub startup {
my $self = shift;
...
$self->hook(
around_action => sub {
my ($next, $c, $action, $last) = @_;
use DDP;
p $c->match;
# prints all the info about the controller and the method/action
# it is going to call
...
}
);
...
}
DDP - 输出
Mojolicious::Routes::Match {
Parents Mojo::Base
public methods (7) : endpoint, find, has, path_for, position, root, stack
private methods (1) : _match
internals: {
endpoint Mojolicious::Routes::Route,
position 0,
root Mojolicious::Routes,
stack [
[0] {
action "controller_method_name",
controller "ControllerClassName",
handler "openapi",
id 3336,
openapi.object Mojolicious::Plugin::OpenAPI,
openapi.op_path [
[0] "paths",
[1] "/api/endpoint/path/{id}/status",
[2] "get"
],
openapi.parameters [
[0] {
description "job id",
in "path",
name "id",
required JSON::PP::Boolean,
type "number"
}
]
}
]
}
}
这是我在$c->match->stack 中寻找的信息:
action "controller_method_name",
controller "ControllerClassName",