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