Endpoint Demo
Showcases all three PAGI endpoint types with middleware.
Run
pagi-server -I lib --app examples/endpoint-demo/app.pl --port 5000
Visit http://localhost:5000/
Features
HTTP Endpoint (REST API)
package MessageAPI;
use parent 'PAGI::Endpoint::HTTP';
async sub get { ... }
async sub post { ... }
WebSocket Endpoint (Echo)
package EchoWS;
use parent 'PAGI::Endpoint::WebSocket';
async sub on_connect { ... }
async sub on_receive { ... }
SSE Endpoint (Notifications)
package MessageEvents;
use parent 'PAGI::Endpoint::SSE';
async sub on_connect { ... }
sub on_disconnect { ... }
Middleware Examples
PAGI::Middleware::AccessLog- Request logging- Coderef middleware - Request timing, JSON validation
Routes
GET/POST /api/messages- REST APIWS /ws/echo- WebSocket echoSSE /events- Live notificationsGET /*- Static files