examples/01-hello-http/app.pl

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 22 / 22 CC 2 SCAR 3.4
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/PAGI/Server/TransportState.pm ↑ Summary
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # Return anonymous coderef directly (avoids "Subroutine redefined" warnings
6 # when file is loaded multiple times via do)
7 29 ▶my $app = async sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
8 29 my ($scope, $receive, $send) = @_;
9 29 ▶ die "Unsupported scope type: $scope->{type}" if $scope->{type} ne 'http';
Branch: 1 branch
BranchTrueFalseTotal
if $scope->{"type"} ne "http" 17 12 29
10  
11 12 await $send->({
12 type => 'http.response.start',
13 status => 200,
14 headers => [ [ 'content-type', 'text/plain' ] ],
15 });
16  
17 #my $timestamp = scalar localtime;
18 12 await $send->({
19 type => 'http.response.body',
20 body => "Hello from PAGI", # bytes; encode explicitly if needed
21 more => 0,
22 });
23 3 };
24  
25 3 $app; # Return coderef when loaded via do
« blib/lib/PAGI/Server/TransportState.pm ↑ Summary