examples/quickstart/app.pl

filter: Statementstmt 74.0% 20 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod n/a totaltotal 75.0% 27 / 36 CC 1 SCAR 1.6
CC
1
Cov
74%
__ANON__
2.0
__ANON__
1.4
__ANON__
1.1
CRAP 1.2
« blib/lib/PAGI/Nano/Context/HTTP.pm ↑ Summary examples/background-tasks/app.pl »
1 2 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Future::AsyncAwait; # handlers that use await must be `async sub`
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use PAGI::Nano;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Quickstart single-file app. Run it with:
7 #
8 # pagi-server app.pl
9 #
10 # The file's last expression is the assembled PAGI app, which pagi-server runs.
11 # (If you add a ./lib, put it on @INC the standard way with
12 # `use FindBin; use lib "$FindBin::Bin/lib";` — Nano never touches @INC.)
13  
14 2 ▶my $app = app {
Subroutine __ANON__: called CC=1 SCAR=1.2
15 0 ▶ startup async sub ($state) { $state->{started} = 1 };
Subroutine __ANON__: not called CC=1 SCAR=3.5
16  
17 2 enable 'GZip';
18  
19 2 ▶ get '/' => sub ($c) { 'Hello from PAGI::Nano' };
Subroutine __ANON__: called CC=1 SCAR=0.0
20  
21 2 ▶ get '/hello/:name' => sub ($c, $name) { { hello => $name } };
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 0 ▶ post '/echo' => async sub ($c) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 my $clean = await $c->params->permitted('message');
25 0 $c->json($clean, status => 201);
26 2 };
27 2 };
28  
29 2 $app;
« blib/lib/PAGI/Nano/Context/HTTP.pm ↑ Summary examples/background-tasks/app.pl »