Changelog and sed s/website authors/application authors/
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Index.pm
CommitLineData
bcccee4e 1package Catalyst::DispatchType::Index;
2
3c0186f2 3use Moose;
4extends 'Catalyst::DispatchType';
0fc2d522 5no Moose;
e8b9f2a9 6
bcccee4e 7=head1 NAME
8
9Catalyst::DispatchType::Index - Index DispatchType
10
11=head1 SYNOPSIS
12
26dc649a 13See L<Catalyst::DispatchType>.
bcccee4e 14
15=head1 DESCRIPTION
16
26dc649a 17Dispatch type managing behaviour for index pages. For more information on
18dispatch types, see:
19
20=over 4
21
b9b89145 22=item * L<Catalyst::Manual::Intro> for how they affect application authors
26dc649a 23
24=item * L<Catalyst::DispatchType> for implementation information.
25
26=back
27
bcccee4e 28=head1 METHODS
29
b5ecfcf0 30=head2 $self->match( $c, $path )
bcccee4e 31
4ab87e27 32Check if there's an index action for a given path, and set it up to use it
b2b90ec2 33if there is; only matches a full URI - if $c->req->args is already set
34this DispatchType is guaranteed not to match.
4ab87e27 35
bcccee4e 36=cut
37
38sub match {
39 my ( $self, $c, $path ) = @_;
bcccee4e 40 return if @{ $c->req->args };
a9dc674c 41 my $result = $c->get_action( 'index', $path );
bcccee4e 42
4082e678 43 if ($result && $result->match($c)) {
b5ecfcf0 44 $c->action($result);
a9dc674c 45 $c->namespace( $result->namespace );
bcccee4e 46 $c->req->action('index');
47 $c->req->match( $c->req->path );
48 return 1;
49 }
50 return 0;
51}
52
ea0e58d9 53=head2 $self->uri_for_action( $action, $captures )
54
55get a URI part for an action; always returns undef is $captures is set
56since index actions don't have captures
57
58=cut
59
60sub uri_for_action {
61 my ( $self, $action, $captures ) = @_;
62
63 return undef if @$captures;
64
65 return undef unless $action->name eq 'index';
66
67 return "/".$action->namespace;
68}
69
2f381252 70=head1 AUTHORS
bcccee4e 71
2f381252 72Catalyst Contributors, see Catalyst.pm
bcccee4e 73
74=head1 COPYRIGHT
75
76This program is free software, you can redistribute it and/or modify it under
77the same terms as Perl itself.
78
79=cut
80
e5ecd5bc 81__PACKAGE__->meta->make_immutable;
82
bcccee4e 831;