1 use CatalystX::Declarative;
3 controller TestApp::Controller::Foo {
18 # normal methods are very useful too
21 method welcome_message { sprintf 'Welcome to %s!', $self->title }
23 method greet (Str $name) { "Hello, $name!" }
30 action base under '/base' as 'foo';
32 action root under base as '' is final {
33 $ctx->response->body( $self->welcome_message );
41 action with_args under base;
43 action hello (Str $name) under with_args is final {
44 $ctx->response->body($self->greet(ucfirst $name));
47 action at_end (Int $x, Int $y) under with_args is final {
48 $ctx->response->body( $x * $y );
51 action in_the_middle (Int $x, Int $y) under with_args {
52 $ctx->stash(result => $x * $y);
54 action end_of_the_middle under in_the_middle is final {
55 $ctx->response->body($ctx->stash->{result} * 2);
58 action all_the_way (Int $x) under with_args as '' {
61 action through_the_sky (Int $y) under all_the_way as '' {
64 action and_beyond (@rest) under through_the_sky as fhtagn is final {
65 $ctx->response->body(join ', ',
74 # under is also a valid keyword
77 under base action under_base as under;
79 under under_base as '' action even_more_under (Int $i) is final {
80 $ctx->response->body("under $i");
85 # too many words? go comma go!
88 action comma_base, as '', under base;
90 under comma_base, is final, action comma ($str), as ',comma' {
91 $ctx->response->body($str);
99 action lower under base;
111 action stream is final {
112 $ctx->response->body(23);