1 package Catalyst::DispatchType::Regex;
4 use base qw/Catalyst::DispatchType::Path/;
8 Catalyst::DispatchType::Regex - Regex DispatchType
20 =item $self->match( $c, $path )
25 my ( $self, $c, $path ) = @_;
27 return if $self->SUPER::match( $c, $path );
29 # Check path against plain text first
31 foreach my $compiled ( @{ $self->{compiled} || [] } ) {
32 if ( my @snippets = ( $path =~ $compiled->{re} ) ) {
33 $c->req->action( $compiled->{path} );
34 $c->req->match($path);
35 $c->req->snippets( \@snippets );
36 $c->action( $compiled->{action} );
37 $c->namespace( $compiled->{action}->prefix );
45 =item $self->register( $c, $action )
50 my ( $self, $c, $action ) = @_;
51 my $attrs = $action->attributes;
52 my @register = map { @{ $_ || [] } } @{$attrs}{ 'Regex', 'Regexp' };
53 foreach my $r (@register) {
54 $self->{paths}{$r} = $action; # Register path for superclass
56 @{ $self->{compiled} }, # and compiled regex for us
71 Sebastian Riedel, C<sri@cpan.org>
75 This program is free software, you can redistribute it and/or modify it under
76 the same terms as Perl itself.