[Catalyst] simple question ... I think ...
Joe Landman
landman at scalableinformatics.com
Sun Aug 13 19:38:15 CEST 2006
Solution... see below ...
Matt S Trout wrote:
> Joe Landman wrote:
>> Ok, being stupid today
>>
>> I have a simple controller named directory. It has a default method.
>> So things named
>>
>> http://localhost:3000/directory
>>
>> should go to it. Now I want to capture
>>
>> http://localhost:3000/directory/other/things/...
>>
>> that is, I want this controller to handle anything past the default
>> method. It does this by default. My question is, how do I get access
>> to the rest of the path after /directory? This is what I have ...
>>
>> sub default : Regex('^(.*)$') {
>> my ( $self, $c, $rest ) = @_;
>> ...
>>
>> }
>
> sub base :Path {
> ...
> }
>
>> and I want $rest to be /other/things/...
>>
>> This is not working though. I tried a Path('/directory') that worked,
>> as long as I gave it /directory/other. As soon as I tried
>> /directory/other/things, it gave me /directory/other.
>
> sub other :Local :Args(0) { ... }
>
> so /directory/other only is matched by that method
>
>> Hmmm...
>>
>> Hints? Clues? FAQs? Pointers?
>
> Catalyst::Manual::Intro has been improved for 5.70 and explains the
> attrs better now.
The hint I needed was that the regex'es are passed in via
$c->request->snippets. This controller definition works nicely.
sub base : Regex('^directory(.*)$') {
my ( $self, $c ) = @_;
my ($rest);
$rest = @{$c->request->snippets}[0];
....
}
Would localregex eliminate the need to hardwire the "directory" in
there? Will play with this...
Thanks.
--
Joe Landman
landman |at| scalableinformatics |dot| com
More information about the Catalyst
mailing list