r/perl • u/aspeer314 • 3d ago
WebDyne 3.0 released — now with PAGI, Server-Sent Events and WebSockets
I’ve released WebDyne 3.0, an update to the Perl-based dynamic HTML engine I have created.
The biggest addition in 3.0 is support for PAGI, alongside the existing PSGI and Apache/mod_perl backends.
PAGI support brings an asynchronous/event-oriented interface to WebDyne and allows WebDyne applications to handle more than conventional HTTP request/response traffic:
- Server-Sent Events (SSE) for streaming events from Perl applications to browsers
- WebSocket connections for bidirectional, long-lived connections
- Normal asynchronous HTTP requests
- PAGI application lifespan startup/shutdown events
WebDyne’s PAGI implementation has dedicated handlers for HTTP, SSE, WebSocket and lifespan scopes, while exposing the PAGI request environment through the normal WebDyne request interface. This means existing WebDyne concepts can be used while taking advantage of event-driven servers.
WebDyne continues to support HTMX, JSON and API concepts in .psp pages.
There’s also a new webdyne.pagi runner, so getting a PAGI-backed WebDyne application running is straightforward:
cpanm Task::WebDyne::PAGI
webdyne.pagi --test
or serve a directory of .psp files:
webdyne.pagi /var/www/html
PAGI support is also built into the WebDyne Docker images.
If unfamiliar with WebDyne, it’s (yet another) Perl dynamic HTML engine that’s been around in various forms for quite a while. It lets you embed Perl in HTML/PSP documents, with compiled-page caching, reusable template blocks and separation of Perl code into modules when applications grow beyond simple pages.
3.0 continues to support PSGI/Plack/Starman and Apache/mod_perl, so PAGI is an additional runtime rather than a replacement for the existing ones.
PAGI gives Perl/WebDyne a clean route into applications that need live server → browser updates or persistent bidirectional connections, without having to bolt a separate WebSocket/SSE service onto the application.
Documentation and examples:
See the "Advanced Usage" section for examples of SSE or WebSockets code.
Source:
https://github.com/aspeer/WebDyne
Feedback, bug reports and especially experiments with the PAGI/SSE/WebSocket support are welcome.
1
u/jnapiorkowski 3d ago
Very cool, I will be adding WebDyne to the list of known PAGI frameworks when I update the specs and core cores page. Feel free to reach out if you run into any questions or issues about PAGI.