Commit | Line | Data |
141459fa |
1 | package TestApp::Controller::Action::ChildOf; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use base qw/Catalyst::Controller/; |
7 | |
8 | sub begin :Private { } |
9 | |
d416846e |
10 | # |
11 | # Simple parent/child action test |
12 | # |
922c58d6 |
13 | sub foo :PathPart('childof/foo') :Captures(1) :ChildOf('/') { } |
922c58d6 |
14 | sub endpoint :PathPart('end') :ChildOf('/action/childof/foo') :Args(1) { } |
d416846e |
15 | |
16 | # |
17 | # Parent/child test with two args each |
18 | # |
19 | sub foo2 :PathPart('childof/foo2') :Captures(2) :ChildOf('/') { } |
922c58d6 |
20 | sub endpoint2 :PathPart('end2') :ChildOf('/action/childof/foo2') :Args(2) { } |
141459fa |
21 | |
d416846e |
22 | # |
23 | # Relative specification of parent action |
24 | # |
7a7ac23c |
25 | sub bar :PathPart('childof/bar') :ChildOf('/') :Captures(0) { } |
09461385 |
26 | sub finale :PathPart('') :ChildOf('bar') :Args { } |
141459fa |
27 | |
d416846e |
28 | # |
29 | # three chain with concurrent endpoints |
30 | # |
922c58d6 |
31 | sub one :PathPart('childof/one') :ChildOf('/') :Captures(1) { } |
32 | sub two :PathPart('two') :ChildOf('/action/childof/one') :Captures(2) { } |
922c58d6 |
33 | sub three_end :PathPart('three') :ChildOf('two') :Args(3) { } |
34 | sub one_end :PathPart('childof/one') :ChildOf('/') :Args(1) { } |
35 | sub two_end :PathPart('two') :ChildOf('one') :Args(2) { } |
36 | |
d416846e |
37 | # |
38 | # Dispatch on number of arguments |
39 | # |
922c58d6 |
40 | sub multi1 :PathPart('childof/multi') :ChildOf('/') :Args(1) { } |
41 | sub multi2 :PathPart('childof/multi') :ChildOf('/') :Args(2) { } |
42 | |
d416846e |
43 | # |
44 | # Roots in an action defined in a higher controller |
45 | # |
46 | sub higher_root :PathPart('bar') :ChildOf('/action/childof/foo/higher_root') :Args(1) { } |
47 | |
48 | # |
49 | # Controller -> subcontroller -> controller |
50 | # |
51 | sub pcp1 :PathPart('childof/pcp1') :ChildOf('/') :Captures(1) { } |
09461385 |
52 | sub pcp3 :ChildOf('/action/childof/foo/pcp2') :Args(1) { } |
d416846e |
53 | |
54 | # |
55 | # Dispatch on capture number |
56 | # |
57 | sub multi_cap1 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(1) { } |
58 | sub multi_cap2 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(2) { } |
59 | sub multi_cap_end1 :PathPart('baz') :ChildOf('multi_cap1') :Args(0) { } |
60 | sub multi_cap_end2 :PathPart('baz') :ChildOf('multi_cap2') :Args(0) { } |
61 | |
62 | # |
63 | # Priority: Slurpy args vs. chained actions |
64 | # |
65 | sub priority_a1 :PathPart('childof/priority_a') :ChildOf('/') :Args { } |
66 | sub priority_a2 :PathPart('childof/priority_a') :ChildOf('/') :Captures(1) { } |
67 | sub priority_a2_end :PathPart('end') :ChildOf('priority_a2') :Args(1) { } |
68 | |
69 | # |
70 | # Priority: Fixed args vs. chained actions |
71 | # |
72 | sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { } |
73 | sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { } |
74 | sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { } |
75 | |
47f9968d |
76 | # |
77 | # Optional specification of :Args in endpoint |
78 | # |
79 | sub opt_args :PathPart('childof/opt_args') :ChildOf('/') { } |
80 | |
141459fa |
81 | sub end :Private { |
82 | my ($self, $c) = @_; |
83 | my $out = join('; ', map { join(', ', @$_) } |
84 | ($c->req->captures, $c->req->args)); |
85 | $c->res->body($out); |
86 | } |
87 | |
88 | 1; |