如何将公共路径转发到另一个 Catalyst 控制器?

发布于 2024-08-16 18:30:12 字数 318 浏览 2 评论 0原文

假设公共 URL /faq 链接到我的 Catalyst 应用程序中的私有路径 /faq/index:

package MyApp::Controller:FAQ;
sub index :Path {
[....]

我如何从另一个控制器转发到 /faq,也就是说我如何知道 URL /faq 的操作是/常见问题解答/索引?像这样的东西:

$c->forward(c->dispatcher->get_action_by_path( "/faq" )); # does not work

Let say the public URL /faq is linked to the private path /faq/index in my Catalyst application:

package MyApp::Controller:FAQ;
sub index :Path {
[....]

How can I do a forward to /faq from another controller, that is how can I know that the action for the URL /faq is /faq/index ? Something like:

$c->forward(c->dispatcher->get_action_by_path( "/faq" )); # does not work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎言笑 2024-08-23 18:30:12

我从 Catalyst 邮件列表中得到了答案:

my $path = "/" . join '/', @{$c->req->args};

$c->request->path($path);
$c->dispatcher->prepare_action($c);

$c->detach($c->action, $c->req->args);

I got the answer for the Catalyst mailing list:

my $path = "/" . join '/', @{$c->req->args};

$c->request->path($path);
$c->dispatcher->prepare_action($c);

$c->detach($c->action, $c->req->args);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文