examples/request-body/app.pl

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 24 / 24 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« examples/psgi-bridge/app.pl ↑ Summary examples/static-file/app.pl »
1 1 ▶use v5.40;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use PAGI::Nano;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Ports PAGI's 03-request-body to PAGI::Nano.
7 # Read the whole request body and echo it back. PAGI::Request->body reads the
8 # http.request events for you, so the handler just awaits it.
9 #
10 # pagi-server app.pl
11 # curl -X POST --data 'hello' http://127.0.0.1:5000/echo
12  
13 1 ▶my $app = app {
Subroutine __ANON__: called CC=1 SCAR=0.0
14 1 ▶ post '/echo' => async sub ($c) {
Subroutine __ANON__: called CC=1 SCAR=0.0
15 1 my $body = await $c->req->body;
16 1 $c->text($body, content_type => 'text/plain; charset=utf-8');
17 1 };
18 1 };
19  
20 1 $app;
« examples/psgi-bridge/app.pl ↑ Summary examples/static-file/app.pl »