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 | |
e5d7f18c |
17 | sub global_action : Private { |
2656a6de |
18 | my ( $self, $c ) = @_; |
19 | $c->forward('TestApp::View::Dump::Request'); |
20 | } |
21 | |
dd4e6fd2 |
22 | sub execute { |
4d989a5d |
23 | my $c = shift; |
24 | my $class = ref( $c->component( $_[0] ) ) || $_[0]; |
25 | my $action = $c->actions->{reverse}->{"$_[1]"} || "$_[1]"; |
dd4e6fd2 |
26 | |
27 | my $method; |
28 | |
4d989a5d |
29 | if ( $action =~ /->(\w+)$/ ) { |
30 | $method = $1; |
dd4e6fd2 |
31 | } |
4d989a5d |
32 | elsif ( $action =~ /\/(\w+)$/ ) { |
33 | $method = $1; |
dd4e6fd2 |
34 | } |
35 | |
4d989a5d |
36 | my $executed = sprintf( "%s->%s", $class, $method ) |
37 | if ( $class && $method ); |
dd4e6fd2 |
38 | |
39 | $c->response->headers->push_header( 'X-Catalyst-Executed' => $executed ); |
40 | return $c->SUPER::execute(@_); |
41 | } |
42 | |
43 | 1; |