File Coverage

examples/01-hello-http/app.pl
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1 5     5   490354 use strict;
  5         10  
  5         238  
2 5     5   21 use warnings;
  5         10  
  5         426  
3 5     5   692 use Future::AsyncAwait;
  5         22229  
  5         46  
4              
5             # Return anonymous coderef directly (avoids "Subroutine redefined" warnings
6             # when file is loaded multiple times via do)
7             my $app = async sub {
8             my ($scope, $receive, $send) = @_;
9             die "Unsupported scope type: $scope->{type}" if $scope->{type} ne 'http';
10              
11             await $send->({
12             type => 'http.response.start',
13             status => 200,
14             headers => [ [ 'content-type', 'text/plain' ] ],
15             });
16              
17             #my $timestamp = scalar localtime;
18             await $send->({
19             type => 'http.response.body',
20             body => "Hello from PAGI", # bytes; encode explicitly if needed
21             more => 0,
22             });
23             };
24              
25             $app; # Return coderef when loaded via do