[Catalyst] Forward on to other actions after removing first path segment?

Dorian Taylor (Lists) dorian.taylor.lists at gmail.com
Mon Nov 15 11:07:42 GMT 2010


Hi all,

Suppose I want to have the first path match a pattern, like an  
ISO-8601 date. I then want to chop it out of the URI path and stash it  
and forward the request on to another handler in the fashion of  
mod_perl's $r->internal_redirect. Consider:

package MyApp;

sub _date :Regex('^(\d{4}-\d{2}-\d{2})$') {
   my ($self, $c, @args) = @_;
   $c->stash->{date} = $c->req->captures->[0];
   # OK now what goes here?
}

I'm ambiguous on two things:

1) I don't understand why an outside request to /foo will find its way  
to /foo/index in MyApp::Foo but a forwarded request will not. I  
understand I'm supposed to use 'visit' or 'go' but they don't seem to  
do it either.
2) I'm not entirely sure about the 'right' way to get the rest of the  
request-URI path. As a (.*) in the regex function attribute? Some  
other way?

Again, my desired effect is to process the rest of the URI path as if  
it was an outside request, after chopping off the first path segment  
and stashing it (if it matches a date).

Insights?

Thanks,

--
Dorian Taylor
Make things. Make sense.
http://doriantaylor.com




More information about the Catalyst mailing list