examples/single/simple_calculator.psgi

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 23 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
__ANON__
1.0
__ANON__
1.0
CRAP 1.0
« examples/single/hello_world.psgi ↑ Summary lib/Dancer2/Core/Role/Engine.pm »
1 1 ▶use Dancer2;
Subroutine BEGIN: called CC=1 SCAR=0.0
2
3 1 ▶get '/' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
4 1 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 1 };
13
14  
15 1 ▶get '/add/:x/:y' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
16 1 my $x = route_parameters->{'x'};
17 1 my $y = route_parameters->{'y'};
18  
19 1 return ($x+$y);
20 1 };
21  
22 1 ▶get '/multiply' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 1 my $x = query_parameters->{'x'};
24 1 my $y = query_parameters->{'y'};
25  
26 1 return ($x*$y);
27 1 };
28  
29 1 ▶post '/division' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
30 1 my $x = body_parameters->{'x'};
31 1 my $y = body_parameters->{'y'};
32  
33 1 return int($x/$y);
34 1 };
35
36 1 __PACKAGE__->to_app;
« examples/single/hello_world.psgi ↑ Summary lib/Dancer2/Core/Role/Engine.pm »