- Added new _DISPATCH private action for dispatching
[catagits/Catalyst-Runtime.git] / t / live / lib / TestApp.pm
1 package TestApp;
2
3 use strict;
4 use Catalyst qw/Test::Errors Test::Headers Test::Plugin/;
5 use Catalyst::Utils;
6
7 our $VERSION = '0.01';
8
9 TestApp->config( name => 'TestApp', root => '/some/dir' );
10
11 TestApp->setup;
12
13 sub index : Private {
14     my ( $self, $c ) = @_;
15     $c->res->body( 'root index' );
16 }
17
18 sub global_action : Private {
19     my ( $self, $c ) = @_;
20     $c->forward('TestApp::View::Dump::Request');
21 }
22
23 sub execute {
24     my $c      = shift;
25     my $class  = ref( $c->component( $_[0] ) ) || $_[0];
26     my $action = "$_[1]";
27
28     my $method;
29
30     if ( $action =~ /->(\w+)$/ ) {
31         $method = $1;
32     }
33     elsif ( $action =~ /\/(\w+)$/ ) {
34         $method = $1;
35     }
36
37     if ( $class && $method && $method !~ /^_/ ) {
38         my $executed = sprintf( "%s->%s", $class, $method );
39         my @executed = $c->response->headers->header('X-Catalyst-Executed');
40         push @executed, $executed;
41         $c->response->headers->header(
42             'X-Catalyst-Executed' => join ', ',
43             @executed
44         );
45     }
46
47     return $c->SUPER::execute(@_);
48 }
49
50 1;