PAGI Examples
This directory contains progressively more advanced PAGI examples. Each subdirectory is prefixed with a two-digit number so you can follow along in order.
Requirements
- Perl 5.18+ with
Future::AsyncAwait - For timers/sleeps:
Future::IO(loop-agnostic) - Run examples with:
pagi-server examples/01-hello-http/app.pl --port 5000
Note: Some advanced examples (job-runner, chat) use IO::Async directly for
timer and subprocess features. These are PAGI::Server-specific patterns.
Examples assume you understand the core spec (docs/specs/main.mkdn) plus the relevant protocol documents.
Example List
01-hello-http- minimal HTTP response02-streaming-response- chunked body, trailers, disconnect handling03-request-body- reads multi-event request bodies04-websocket-echo- handshake and echo loop05-sse-broadcaster- server-sent events06-lifespan-state- lifespan protocol with shared state07-extension-fullflush- middleware using thefullflushextension08-tls-introspection- prints TLS metadata when present09-psgi-bridge- wraps a PSGI app for PAGI use (viaPAGI::App::WrapPSGI)10-chat-showcase- WebSocket chat demo with multiple clients11-job-runner- background job processing example12-utf8- UTF-8 handling demonstration13-contact-form- form parsing and file uploads14-lifespan-utils- lifespan hooks via PAGI::Utils
Built-in Apps
Additional example apps are bundled in lib/PAGI/App/:
app-01-file- static file serving with PAGI::App::File
Each example has its own README.md explaining how to run it and which spec sections to review.