| 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 PAGI::Nano; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | # Ports PAGI's 12-utf8 to PAGI::Nano. | ||
| 6 | # UTF-8 round-trips across the input vectors: the path segment (already decoded | ||
| 7 | # by PAGI) and the query string. Nano's JSON coercion encodes UTF-8 for you. | ||
| 8 | # | ||
| 9 | # pagi-server app.pl | ||
| 10 | # curl http://127.0.0.1:5000/echo/héllo | ||
| 11 | # curl 'http://127.0.0.1:5000/echo/x?text=naïve' | ||
| 12 | |||
| 13 | 1 | ▶ | my $app = app { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | get '/echo/:word' => sub ($c, $word) { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 15 | { | ||
| 16 | 1 | from_path => $word, # decoded by PAGI | |
| 17 | from_query => $c->req->query_param('text'), # decoded by Request | ||
| 18 | length => length($word), # characters, not bytes | ||
| 19 | }; | ||
| 20 | 1 | }; | |
| 21 | 1 | }; | |
| 22 | |||
| 23 | 1 | $app; | |