如何使用 Config::General 在给定控制器中配置所有 Catalyst 操作?
我想使用我的应用程序的配置文件配置控制器中的所有操作。根据 Catalyst::Controller 我可以在控制器本身中执行此操作:
__PACKAGE__->config(
action => {
'*' => { Chained => 'base', Args => 0 },
},
);
所以我在我的配置中尝试了此操作:
<controller Foo>
<action "*">
Chained base
Args 0
</action>
</controller>
但是我在启动时收到此错误:
Couldn't load class (MyApp) because: Action "*" is not available from
controller MyApp::Controller::Foo at /usr/local/share/perl/5.10.1/Catalyst/
Controller.pm line 193
它在没有星号周围的引号的情况下执行相同的操作。我该怎么做?
I want to configure all the actions in my controller using my app's config file. According to Catalyst::Controller I can do this in the controller itself:
__PACKAGE__->config(
action => {
'*' => { Chained => 'base', Args => 0 },
},
);
So I tried this in my config:
<controller Foo>
<action "*">
Chained base
Args 0
</action>
</controller>
But I get this error on startup:
Couldn't load class (MyApp) because: Action "*" is not available from
controller MyApp::Controller::Foo at /usr/local/share/perl/5.10.1/Catalyst/
Controller.pm line 193
It does the same without the quotes around the asterisk. How should I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Catalyst 权威指南中对此进行了介绍,
从该页面获取可下载的源代码,将其解压缩,转到第 7 章中的 DwarfChains 应用程序,然后将以下内容添加到 dwarfchains.conf:
这或多或少应该演示如何通过配置覆盖调度。
This is covered in The Definitive Guide to Catalyst
Grab the downloadable source from that page, unzip it, go to the DwarfChains application in chapter 7, then add the following to dwarfchains.conf:
That should more or less demonstrate how to override dispatch by configuration.