| examples/single/simple_calculator.psgi | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 3 | 3 | 100.0 |
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 1 | 1 | 100.0 |
| pod | n/a | ||
| total | 4 | 4 | 100.0 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 437765 | use Dancer2; | |||
| 1 | 5 | ||||||
| 1 | 5 | ||||||
| 2 | |||||||
| 3 | get '/' => sub { | ||||||
| 4 | return q{Welcome to simple calculator, powered by Dancer2. | ||||||
| 5 | add 2 + 3 | ||||||
| 6 | multiply | ||||||
| 7 | |||||||
| 8 | |||||||
| 9 | |||||||
| 10 | |||||||
| 11 | }; | ||||||
| 12 | }; | ||||||
| 13 | |||||||
| 14 | |||||||
| 15 | get '/add/:x/:y' => sub { | ||||||
| 16 | my $x = route_parameters->{'x'}; | ||||||
| 17 | my $y = route_parameters->{'y'}; | ||||||
| 18 | |||||||
| 19 | return ($x+$y); | ||||||
| 20 | }; | ||||||
| 21 | |||||||
| 22 | get '/multiply' => sub { | ||||||
| 23 | my $x = query_parameters->{'x'}; | ||||||
| 24 | my $y = query_parameters->{'y'}; | ||||||
| 25 | |||||||
| 26 | return ($x*$y); | ||||||
| 27 | }; | ||||||
| 28 | |||||||
| 29 | post '/division' => sub { | ||||||
| 30 | my $x = body_parameters->{'x'}; | ||||||
| 31 | my $y = body_parameters->{'y'}; | ||||||
| 32 | |||||||
| 33 | return int($x/$y); | ||||||
| 34 | }; | ||||||
| 35 | |||||||
| 36 | __PACKAGE__->to_app; |