最简练有效的catalyst的action总结

博客介绍了Catalyst的action相关内容。Catalyst有Local、Regex、Private、Path等多种类型的action,新应用倾向用Path和Args属性。还提到dispatcher自动“链接”action的强大功能,以及五种内置Private action的特点,如auto action会在命名空间链中被调用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://search.cpan.org/~zarquon/Catalyst-Manual-5.7013/lib/Catalyst/Manual/Tutorial/Authentication.pod

在上边的链接里边有对catalyst的action最简练有效的总结,如下:

Note: Catalyst provides a number of different types of actions, such as Local, Regex, Private and the new Path. You should refer to Catalyst::Manual::Intro for a more detailed explanation, but the following bullet points provide a quick introduction:

  • The majority of application have traditionally used Local actions for items that respond to user requests and Private actions for those that do not directly respond to user input.
  • Newer Catalyst applications tend to use Path actions and the Args attribute because of their power and flexibility. You can specify the path to match relative to the namespace of the current module as an argument to Path. For example Path('list') in lib/MyApp/Controller/Books.pm would match on the URL http://localhost:3000/books/list but Path('/list') would match on http://localhost:3000/list.
  • Automatic "chaining" of actions by the dispatcher is a powerful feature that allows multiple methods to handle a single URL. See Catalyst::DispatchType::Chained for more information on chained actions.
  • There are five types of build-in Private actions: begin, end, default, index, and auto.
  • With begin, end, default, index private actions, only the most specific action of each type will be called. For example, if you define a begin action in your controller it will override a begin action in your application/root controller -- only the action in your controller will be called.
  • Unlike the other actions where only a single method is called for each request, every auto action along the chain of namespaces will be called. Each auto action will be called from the application/root controller down through the most specific class.

By placing the authentication enforcement code inside the auto method of lib/MyApp/Controller/Root.pm (or lib/MyApp.pm), it will be called for every request that is received by the entire application.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/82392/viewspace-467905/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/82392/viewspace-467905/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值