| 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::App::WrapPSGI; |
|
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-Tools' 09-psgi-bridge to PAGI::Nano. | ||
| 7 | # A legacy synchronous PSGI app is wrapped by PAGI::App::WrapPSGI (which adapts it | ||
| 8 | # to the async PAGI interface) and mounted under a prefix — so old PSGI code runs | ||
| 9 | # alongside native Nano routes in the same app. | ||
| 10 | # | ||
| 11 | # pagi-server app.pl | ||
| 12 | # curl http://127.0.0.1:5000/legacy/anything | ||
| 13 | |||
| 14 | 1 | ▶ | my $psgi_app = sub ($env) { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 15 | 1 | my $body = "PSGI app saw: $env->{REQUEST_METHOD} $env->{PATH_INFO}"; | |
| 16 | 1 | return [200, ['Content-Type' => 'text/plain'], [$body]]; | |
| 17 | 1 | }; | |
| 18 | |||
| 19 | 1 | ▶ | my $app = app { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 20 | 1 | ▶ | get '/' => sub ($c) { 'Native Nano route; /legacy is a mounted PSGI app' }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 1 | mount '/legacy' => PAGI::App::WrapPSGI->new(psgi_app => $psgi_app); | |
| 23 | 1 | }; | |
| 24 | |||
| 25 | 1 | $app; | |