File Coverage

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   834 use Dancer2;
  1         4  
  1         6  
2            
3             get '/' => sub {
4             return q{Welcome to simple calculator, powered by Dancer2.
5             <a href="/add/2/3">add 2 + 3</a>
6             <a href="/multiply?x=2&y=3">multiply</a>
7             <form method="POST" action="/division">
8             <input name="x"><input name="y">
9             <input type="submit" value="Division">
10             </form>
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;