开发者

How can I configure all the Catalyst actions in a given controller using Config::General?

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::Controlle开发者_高级运维r::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?


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:

 <Controller People>
 <action get_ready>
  PathPart nama
 </action>
 </Controller>

 <Controller People::Info>
 <action get_info_ready>
  PathPart siapa
 </action >
 <action create>
  PathPart lagi
 </action >
 <action delete>
  PathPart mengusir
 </action >
 </Controller>

That should more or less demonstrate how to override dispatch by configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜