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