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