1 package TestApp::Controller::Action::ChildOf;
6 use base qw/Catalyst::Controller/;
12 # :ChildOf('') defaulting to controller namespace
13 # :ChildOf('..') defaulting to action in controller above
14 # :ChildOf == ChildOf('/')
18 # Simple parent/child action test
20 sub foo :PathPart('childof/foo') :Captures(1) :ChildOf('/') { }
21 sub endpoint :PathPart('end') :ChildOf('/action/childof/foo') :Args(1) { }
24 # Parent/child test with two args each
26 sub foo2 :PathPart('childof/foo2') :Captures(2) :ChildOf('/') { }
27 sub endpoint2 :PathPart('end2') :ChildOf('/action/childof/foo2') :Args(2) { }
30 # Relative specification of parent action
32 sub bar :PathPart('childof/bar') :ChildOf('/') :Captures(0) { }
33 sub finale :PathPart('') :ChildOf('bar') :Args { }
36 # three chain with concurrent endpoints
38 sub one :PathPart('childof/one') :ChildOf('/') :Captures(1) { }
39 sub two :PathPart('two') :ChildOf('/action/childof/one') :Captures(2) { }
40 sub three_end :PathPart('three') :ChildOf('two') :Args(3) { }
41 sub one_end :PathPart('childof/one') :ChildOf('/') :Args(1) { }
42 sub two_end :PathPart('two') :ChildOf('one') :Args(2) { }
45 # Dispatch on number of arguments
47 sub multi1 :PathPart('childof/multi') :ChildOf('/') :Args(1) { }
48 sub multi2 :PathPart('childof/multi') :ChildOf('/') :Args(2) { }
51 # Roots in an action defined in a higher controller
53 sub higher_root :PathPart('bar') :ChildOf('/action/childof/foo/higher_root') :Args(1) { }
56 # Controller -> subcontroller -> controller
58 sub pcp1 :PathPart('childof/pcp1') :ChildOf('/') :Captures(1) { }
59 sub pcp3 :ChildOf('/action/childof/foo/pcp2') :Args(1) { }
62 # Dispatch on capture number
64 sub multi_cap1 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(1) { }
65 sub multi_cap2 :PathPart('childof/multi_cap') :ChildOf('/') :Captures(2) { }
66 sub multi_cap_end1 :PathPart('baz') :ChildOf('multi_cap1') :Args(0) { }
67 sub multi_cap_end2 :PathPart('baz') :ChildOf('multi_cap2') :Args(0) { }
70 # Priority: Slurpy args vs. chained actions
72 sub priority_a1 :PathPart('childof/priority_a') :ChildOf('/') :Args { }
73 sub priority_a2 :PathPart('childof/priority_a') :ChildOf('/') :Captures(1) { }
74 sub priority_a2_end :PathPart('end') :ChildOf('priority_a2') :Args(1) { }
77 # Priority: Fixed args vs. chained actions
79 sub priority_b1 :PathPart('childof/priority_b') :ChildOf('/') :Args(3) { }
80 sub priority_b2 :PathPart('childof/priority_b') :ChildOf('/') :Captures(1) { }
81 sub priority_b2_end :PathPart('end') :ChildOf('priority_b2') :Args(1) { }
84 # Optional specification of :Args in endpoint
86 sub opt_args :PathPart('childof/opt_args') :ChildOf('/') { }
89 # Optional PathPart test -> /childof/optpp/*/opt_pathpart/*
91 sub opt_pp_start :ChildOf('/') :PathPart('childof/optpp') :Captures(1) { }
92 sub opt_pathpart :ChildOf('opt_pp_start') :Args(1) { }
95 # Optional Args *and* PathPart -> /childof/optall/*/oa/...
97 sub opt_all_start :ChildOf('/') :PathPart('childof/optall') :Captures(1) { }
98 sub oa :ChildOf('opt_all_start') { }
102 my $out = join('; ', map { join(', ', @$_) }
103 ($c->req->captures, $c->req->args));