| 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
| |||||||||||
| 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 | |||||||||