1 use CatalystX::Declare;
3 # this "calculator" (mind the quotes) is extendable by the model
4 controller MyApp::Web::Controller::Calc {
6 # we base of the common base in the root controller
7 action base as calc under '/base';
9 # we fetch our operator from the model in an action attached to the base
10 action operator <- base (Str $op) as '' {
11 $ctx->stash(operator => $ctx->model('Calc')->op($op));
14 # here we know we have an operator and run it against the integers we got
15 final action evaluate <- operator (Int @nums) as '' {
16 $ctx->response->body($ctx->stash->{operator}->(@nums));