sub details : Regex('^product/(\w+)/details$') {
my ( $self, $c ) = @_;
# extract the (\w+) from the URI
- my $product = $c->req->snippets->[0];
+ my $product = $c->req->captures->[0];
}
See L<Catalyst::Manual::Intro> for additional information.
my $basepath = $base->path;
$basepath =~ s/\/$//;
$basepath .= '/';
- my $namespace = $c->namespace;
+ my $namespace = $c->namespace || '';
# massage namespace, empty if absolute path
$namespace =~ s/^\///;
parameters => {},
query_parameters => {},
secure => 0,
- snippets => [],
+ captures => [],
uploads => {}
}
),
# Check path against plain text first
foreach my $compiled ( @{ $self->{compiled} || [] } ) {
- if ( my @snippets = ( $path =~ $compiled->{re} ) ) {
+ if ( my @captures = ( $path =~ $compiled->{re} ) ) {
next unless $compiled->{action}->match($c);
$c->req->action( $compiled->{path} );
$c->req->match($path);
- $c->req->snippets( \@snippets );
+ $c->req->captures( \@captures );
$c->action( $compiled->{action} );
$c->namespace( $compiled->{action}->namespace );
return 1;
For both LocalRegex and Regex actions, if you use capturing parentheses
to extract values within the matching URL, those values are available in
-the C<$c-E<gt>req-E<gt>snippets> array. In the above example, "widget23"
+the C<$c-E<gt>req-E<gt>captures> array. In the above example, "widget23"
would capture "23" in the above example, and
-C<$c-E<gt>req-E<gt>snippets-E<gt>[0]> would be "23". If you want to pass
+C<$c-E<gt>req-E<gt>captures-E<gt>[0]> would be "23". If you want to pass
arguments at the end of your URL, you must use regex action keys. See
L</URL Path Handling> below.
__PACKAGE__->mk_accessors(
qw/action address arguments cookies headers match method
- protocol query_parameters secure snippets uri user/
+ protocol query_parameters secure captures uri user/
);
*args = \&arguments;
*params = \¶meters;
*query_params = \&query_parameters;
*path_info = \&path;
+*snippets = \&captures;
sub content_encoding { shift->headers->content_encoding(@_) }
sub content_length { shift->headers->content_length(@_) }
$req->read;
$req->referer;
$req->secure;
- $req->snippets;
+ $req->captures; # previously knows as snippets
$req->upload;
$req->uploads;
$req->uri;
Returns true or false, indicating whether the connection is secure (https).
-=head2 $req->snippets
+=head2 $req->captures
+
+Returns a reference to an array containing regex captures.
-Returns a reference to an array containing regex snippets.
+ my @captures = @{ $c->request->captures };
+
+=head2 $req->snippets
- my @snippets = @{ $c->request->snippets };
+C<captures> used to be called snippets. This is still available for backwoards
+compatibility, but is considered deprecated.
=head2 $req->upload