Commit | Line | Data |
fd91d0c6 |
1 | package TestApp::Controller::Action::Chained::CaptureArgs; |
2 | use warnings; |
3 | use strict; |
4 | |
5 | use base qw( Catalyst::Controller ); |
6 | |
7 | # |
8 | # This controller builds two patterns of URI: |
9 | # /captureargs/*/* |
10 | # /captureargs/*/*/edit |
11 | # /captureargs/* |
12 | # /captureargs/*/edit |
13 | # It will output the arguments they got passed to @_ after the |
14 | # context object. |
15 | # /captureargs/one/edit should not dispatch to |
16 | # /captureargs/*/* |
17 | |
18 | sub base :Chained('/') PathPart('captureargs') CaptureArgs(0) { |
19 | my ( $self, $c, $arg ) = @_; |
20 | push @{ $c->stash->{ passed_args } }, 'base'; |
21 | } |
22 | |
23 | sub two_args :Chained('base') PathPart('') CaptureArgs(2) { |
24 | my ( $self, $c, $arg1, $arg2 ) = @_; |
25 | push @{ $c->stash->{ passed_args } }, 'two_args', $arg1, $arg2; |
26 | } |
27 | |
28 | sub one_arg :Chained('base') ParthPart('') CaptureArgs(1) { |
29 | my ( $self, $c, $arg ) = @_; |
30 | push @{ $c->stash->{ passed_args } }, 'one_arg', $arg; |
31 | } |
32 | |
33 | sub edit_two_args :Chained('two_args') PathPart('edit') Args(0) { |
34 | my ( $self, $c ) = @_; |
35 | push @{ $c->stash->{ passed_args } }, 'edit_two_args'; |
36 | } |
37 | |
38 | sub edit_one_arg :Chained('one_arg') PathPart('edit') Args(0) { |
39 | my ( $self, $c ) = @_; |
40 | push @{ $c->stash->{ passed_args } }, 'edit_one_arg'; |
41 | } |
42 | |
43 | sub view_two_args :Chained('two_args') PathPart('') Args(0) { |
44 | my ( $self, $c ) = @_; |
45 | push @{ $c->stash->{ passed_args } }, 'view_two_args'; |
46 | } |
47 | |
48 | sub view_one_arg :Chained('one_arg') PathPart('') Args(0) { |
49 | my ( $self, $c ) = @_; |
50 | push @{ $c->stash->{ passed_args } }, 'view_one_arg'; |
51 | } |
52 | |
53 | |
54 | sub end : Private { |
55 | my ( $self, $c ) = @_; |
56 | no warnings 'uninitialized'; |
57 | $c->response->body( join '; ', @{ $c->stash->{ passed_args } } ); |
58 | } |
59 | |
60 | 1; |