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 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.
I blog about Perl.
Leave a comment