http.pubsub Plugin

This feature does not come with Caddy by default. To get it, select the http.pubsub plugin when you download Caddy.

The pubsub plugin implements a longpoll-based publish and subscribe middleware for Caddy. It lets you easily push event notifications to any practical number of web clients. To publish an event, post content that includes a category and body to the “publish” URL configured in the Caddyfile. To subscribe to published events, simply connect your web client to the “subscribe” URL configured in the Caddyfile. To manage the subscription connection, include the small, dependency-free file ps.js in your web application and use the non-blocking methods of a Subscriber instance.

Full documentation

Examples

Simple publish and subscribe example

In the Caddyfile: pubsub /chat/publish /chat/subscribe From a browser or wget: https://example.com/chat/publish?category=team&body=Hello%20world

In this example, the body “Hello world” is dispatched to all subscribers of the “team” category. In general, you will want to restrict access to the publish and subscribe URLs, something that this example does not demonstrate.

Related Links

Documentation

Access the full documentation for this plugin off-site:

Docs

Plugin Help

Get help from the maintainers of the http.pubsub plugin:

Support

Plugin Website

Visit http.pubsub’s website for more information:

Website

Plugin Author: Kurt Jung

Last Updated: 14 Jun 2019, 7:16 PM

This plugin is independent of the Caddy project and is not endorsed or maintained by Caddy developers. Use at your own risk. Do not file issues for this plugin on Caddy’s bug tracker.