Merged 5.49_01 (r1339) from refactored branch to trunk
[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 global_action : Private {
14     my ( $self, $c ) = @_;
15     $c->forward('TestApp::View::Dump::Request');
16 }
17
18 sub execute {
19     my $c      = shift;
20     my $class  = ref( $c->component( $_[0] ) ) || $_[0];
21     my $action = "$_[1]";
22
23     my $method;
24
25     if ( $action =~ /->(\w+)$/ ) {
26         $method = $1;
27     }
28     elsif ( $action =~ /\/(\w+)$/ ) {
29         $method = $1;
30     }
31
32     if ( $class && $method ) {
33         my $executed = sprintf( "%s->%s", $class, $method );
34         my @executed = $c->response->headers->header('X-Catalyst-Executed');
35         push @executed, $executed;
36         $c->response->headers->header(
37             'X-Catalyst-Executed' => join ', ',
38             @executed
39         );
40     }
41
42     return $c->SUPER::execute(@_);
43 }
44
45 1;