Commit | Line | Data |
1754e3e7 |
1 | use CatalystX::Declare; |
2 | |
3 | controller_role TestApp::ControllerRole::DynamicFinal ( |
4 | Bool :$is_final, |
5 | Str :$body, |
6 | Str :$base = "base", |
7 | ArrayRef[Str] :$counters = [] |
8 | ) { |
9 | |
10 | method set_body (Object $ctx) { |
11 | $ctx->response->body($body); |
12 | } |
13 | |
14 | if ($is_final) { |
15 | |
16 | final action msg under $base { $self->set_body($ctx) } |
17 | } |
18 | |
19 | else { |
20 | |
21 | action msg under $base { $self->set_body($ctx) } |
22 | } |
23 | |
24 | for my $counter (@$counters) { |
25 | my $count = 0; |
26 | |
27 | final action "count_$counter" under $base as "counter/$counter" { |
28 | $ctx->response->body($count++); |
29 | } |
30 | } |
31 | } |