Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / t / lib / TestApp.pm
1 package TestApp;
2
3 use strict;
4 use Catalyst qw[Test::Errors Test::Headers];
5 use Catalyst::Utils;
6
7 our $VERSION = '0.01';
8
9 TestApp->config(
10     name => 'TestApp',
11     root => '/Users/chansen/src/MyApp/root',
12 );
13
14 TestApp->setup;
15
16 #sub execute { return shift->NEXT::execute(@_); } # does not work, bug?
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 = $c->actions->{reverse}->{"$_[1]"} || "$_[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 ) {
38         my $executed = sprintf( "%s->%s", $class, $method );
39         $c->response->headers->push_header( 'X-Catalyst-Executed' => $executed );
40     }
41     
42     return $c->SUPER::execute(@_);
43 }
44
45 1;