Commit | Line | Data |
dd4e6fd2 |
1 | package TestApp; |
2 | |
3 | use strict; |
4 | use Catalyst qw[Test::Errors Test::Headers]; |
5 | |
6 | our $VERSION = '0.01'; |
7 | |
8 | TestApp->config( |
9 | name => 'TestApp', |
10 | root => '/Users/chansen/src/MyApp/root', |
11 | ); |
12 | |
13 | TestApp->setup; |
14 | |
15 | #sub execute { return shift->NEXT::execute(@_); } # does not work, bug? |
16 | |
17 | sub execute { |
18 | my $c = shift; |
19 | my $class = ref( $c->component($_[0]) ) || $_[0]; |
20 | my $action = $c->actions->{reverse}->{"$_[1]"} || "$_[1]"; |
21 | |
22 | my $method; |
23 | |
24 | if ( $action =~ /->(\w+)$/ ) { |
25 | $method = $1; |
26 | } |
27 | elsif ( $action =~ /\/(\w+)$/ ) { |
28 | $method = $1; |
29 | } |
30 | |
31 | my $executed = sprintf( "%s->%s", $class, $method ); |
32 | |
33 | $c->response->headers->push_header( 'X-Catalyst-Executed' => $executed ); |
34 | return $c->SUPER::execute(@_); |
35 | } |
36 | |
37 | 1; |