[Catalyst] How do I have Catalyst access a Controller based on only part of the PATH_INFO

Matt S Trout dbix-class at trout.me.uk
Fri May 11 16:36:08 GMT 2007


On Sat, May 12, 2007 at 12:20:53AM +1000, Steve H wrote:
> Hi
> 
> I'm used to (albeit a recent Catalyst convert) creating a Controller based 
> on the whole name of the PATH_INFO, e.g.
>  http://localhost:3000/some/structure/like/this
> being:
>  package my_app::Controller::some::structure::like::this
> In a file my_app/lib/my_app/Controller/some/structure/like/this.pm
> How would I have a Controller like:
>  package my_app::Controller::some::structure
> In a file my_app/lib/my_app/Controller/some/structure.pm
> and be able to access the remaining "like/this" via PATH_INFO.

That's actually how actions work by default - an action with a public
URL of /foo/bar will also match /foo/bar/baz/quux/tickle/me/elmo/whatever
unless you explicitly set the number of extra arguments via :Args(0)
(for /foo/bar only), :Args(1) for (/foo/bar/*), ...

This is why you often see code written as

sub bar :Local {
  my ($self, $c, @args) = @_;
  ...
}

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list