[Catalyst] simple question ... I think ...
Matt S Trout
dbix-class at trout.me.uk
Sun Aug 13 20:29:03 CEST 2006
Joe Landman wrote:
> Solution... see below ...
>
> 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...
>
Yes, but you still don't need to use a regex action.
sub base :Path {
my ($self, $c, @parts) = @_;
my $rest = join('/', @parts);
...
}
If you're using a Regex action, always first ask yourself "is there an
easier way to do this?". The answer is almost always yes.
More information about the Catalyst
mailing list