1 package Catalyst::DispatchType::Index;
4 extends 'Catalyst::DispatchType';
5 use namespace::clean -except => 'meta';
9 Catalyst::DispatchType::Index - Index DispatchType
13 See L<Catalyst::DispatchType>.
17 Dispatch type managing behaviour for index pages. For more information on
22 =item * L<Catalyst::Manual::Intro> for how they affect application authors
24 =item * L<Catalyst::DispatchType> for implementation information.
31 is => 'rw', isa => 'HashRef', default => sub { +{} }
36 =head2 $self->match( $c, $path )
38 Check if there's an index action for a given path, and set it up to use it
39 if there is; only matches a full URI - if $c->req->args is already set
40 this DispatchType is guaranteed not to match.
45 my ( $self, $c, $path ) = @_;
46 return if @{ $c->req->args };
47 my $result = $c->get_action( 'index', $path );
49 return 0 unless $result && exists $self->_actions->{ $result->reverse };
51 if ($result && $result->match($c)) {
53 $c->namespace( $result->namespace );
54 $c->req->action('index');
55 $c->req->match( $c->req->path );
61 =head2 $self->register( $c, $action )
63 Register an action with this DispatchType.
68 my ( $self, $c, $action ) = @_;
70 $self->_actions->{ $action->reverse } = $action if $action->name eq 'index';
75 =head2 $self->uri_for_action( $action, $captures )
77 get a URI part for an action; always returns undef is $captures is set
78 since index actions don't have captures
83 my ( $self, $action, $captures ) = @_;
85 return undef if @$captures;
87 return undef unless exists $self->_actions->{ $action->reverse };
89 return "/".$action->namespace;
92 sub _is_low_precedence { 1 }
96 Catalyst Contributors, see Catalyst.pm
100 This library is free software. You can redistribute it and/or modify it under
101 the same terms as Perl itself.
105 __PACKAGE__->meta->make_immutable;