[Catalyst] Sanity Check -- requesting feedback on chaining approach

Dave Rolsky autarch at urth.org
Wed Feb 16 17:08:33 GMT 2011


On Tue, 15 Feb 2011, will trillich wrote:

> Does this seem like a "best practice"? Comments welcome.

Personally, my take on best practices for chaining is basically "make sane 
RESTful URIs".

I like to name my non-public chain point with private subs, and I like
my end points to be descriptive. So given that, I'd probably do
something like:

   package MyApp::Controller::Xyzzy;

   sub _set_xyzzy  : Chained               PathPart('xyzzy') CaptureArgs(0) {  }
     sub list      : Chained('_set_xyzzy') PathPart('')      Args(0)        {  }
     # CSV dispatch based on Accept header, not URI!
     sub _set_item : Chained('_set_xyzzy') PathPart('')      CaptureArgs(1) {  }
     sub item      : Chained('item')       PathPart('')      Args(0)        {  }

Although nowadays I've started using CX::Routes, which lets me _not_
name the subs themselves. I actually like this, since the subroutine
names don't participate in routing when you use chaining.


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/



More information about the Catalyst mailing list