1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
package TestApp::Controller::Action::Action;
use utf8;
use strict;
use base 'TestApp::Controller::Action';
use Data::Dumper ();
__PACKAGE__->config(
actions => {
'*' => { extra_attribute => 13 },
action_action_five => { ActionClass => '+Catalyst::Action::TestBefore' },
action_action_eight => { another_extra_attribute => 'foo' },
},
action_args => {
'*' => { extra_arg => 42 },
action_action_seven => { another_extra_arg => 23 },
},
);
sub action_action_one : Global : ActionClass('TestBefore') {
my ( $self, $c ) = @_;
$c->res->header( 'X-Action', $c->stash->{test} );
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_two : Global : ActionClass('TestAfter') {
my ( $self, $c ) = @_;
$c->stash->{after_message} = 'awesome';
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_three : Global : ActionClass('+TestApp::Action::TestBefore') {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_four : Global : MyAction('TestMyAction') {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_five : Global {
my ( $self, $c ) = @_;
$c->res->header( 'X-Action', $c->stash->{test} );
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_six : Global : ActionClass('~TestMyAction') {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_seven : Global : ActionClass('~TestExtraArgsAction') {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Request');
}
sub action_action_eight : Global {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Action');
}
sub action_action_nine : Global : ActionClass('~TestActionArgsFromConstructor') {
my ( $self, $c ) = @_;
$c->forward('TestApp::View::Dump::Request');
}
# For testing the regex that parses method attributes
sub action_action_ten :Global
:Foo
:Foo()
:Foo(bar)
:Foo("bar")
:Foo(aaa bbb ccc. dddd)
:Foo(12345)
:Foo( bar )
:Foo("bar baz")
:Foo(bar baz )
:Foo(bar(baz))
:Foo(^$.*+?)
:Foo(bar\)baz)
:Foo(ba\\nr)
:Foo(ba\tr)
:Foo(bar, baz)
:Foo(bar;baz)
:Foo(bar&baz)
:Foo(bar=1)
:Foo( { "a":"b"})
:Foo(bar=1, baz=2)
:Foo( bar=1, baz=2, qux=3 )
:Foo(" bar=1, baz=2, qux=3 ")
:Foo( " bar=1, baz=2, qux=3 ")
:Foo(' bar=1, baz=2, qux=3 ')
:Foo([ bar=1, baz=2, qux=3 ])
:Foo(bar: baz)
:Foo(中文测试)
:Foo("bar's baz")
:Foo(😀 emoji test)
:Foo(#comment)
:Foo("fff\nfff")
:Foo("\taaa\nbbb")
:Foo('bar's baz')
:Foo( )
:Foo([.*?^$])
:Foo(
)
:Foo(
aaa
bbb😀 ccc
ddd
)
:Foo("
aaa
bbb😀 ccc
ddd
")
:Foo(
'aaa'
'bbb😀' 'ccc'
'ddd'
)
:Foo("
'aaa'
'bbb😀' 'ccc'
'ddd'
")
{
my ( $self, $c ) = @_;
$c->response->body(Data::Dumper::Dumper($c->action->attributes->{Foo}));
}
1;
|