Go server for handling WebSub, supporting custom implementations of content providers.

Go WebSub Server

A Go implementation of a WebSub server.

See examples/main.go for a basic example which uses boltdb and a simple publisher.

Importing:

go get meow.tf/websub

Stores

Specific stores can be implemented/used to store subscriptions and call them.

If you'd like to implement your own store, the following interface can be implemented:

type Store interface {
	All(topic string) ([]model.Subscription, error)
	Add(sub model.Subscription) error
	Get(topic, callback string) (*model.Subscription, error)
	Remove(sub model.Subscription) error
}

Memory

A memory-backed store. This store is cleared when the application is restarted.

Bolt

A boltdb/bbolt backed store which persists to disk.

Workers

This hub system uses Workers to implement a system that can be infinitely scaled by adding other nodes/servers and workers which can pull off a queue.

By default, the worker pool is a basic channel + goroutine handler that goes through each request.

type Worker interface {
    Add(f PublishJob)
    Start()
    Stop()
}

When implementing workers, pay attention to the fields. ContentType is used to say what the body content type is (required by the specification), and if subscription.secret is set it MUST be used to generate an X-Hub-Signature header.

Using it with your own Publisher

If you wish to bypass the included hub.mode=publish handler, you can use the Publish function to publish your own data.

For example, if you're taking an event off some kind of queue/event subscriber:

hub.Publish("https://example.com", "application/json", []byte("{}"))
Owner
Tyler Stuyfzand
Just someone who likes to create simple and easy to use packages, Discord bots, and many other things. Any opinions and code on here are my own.
Tyler Stuyfzand
Similar Resources

A feature flag solution, with only a YAML file in the backend (S3, GitHub, HTTP, local file ...), no server to install, just add a file in a central system and refer to it. πŸŽ›οΈ

A feature flag solution, with only a YAML file in the backend (S3, GitHub, HTTP, local file ...), no server to install, just add a file in a central system and refer to it. πŸŽ›οΈ

πŸŽ›οΈ go-feature-flag A feature flag solution, with YAML file in the backend (S3, GitHub, HTTP, local file ...). No server to install, just add a file i

Dec 29, 2022

An XMPP server written in Go (Golang).

jackal An XMPP server written in Go. About jackal is a free, open-source, high performance XMPP server which aims to be known for its stability, simpl

Dec 29, 2022

A proxy server than converts JSON request bodies to protocol buffers

A proxy server than converts JSON request bodies to protocol buffers

Welcome to Protoxy πŸ‘‹ What is Protoxy? Protoxy allows you to test your REST APIs that use Protocol Buffer serialization through Postman and other API

Nov 1, 2022

High-performance PHP application server, load-balancer and process manager written in Golang

High-performance PHP application server, load-balancer and process manager written in Golang

[RR2-BETA] RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports runnin

Jan 4, 2023

Fully featured and highly configurable SFTP server with optional FTP/S and WebDAV support - S3, Google Cloud Storage, Azure Blob

SFTPGo Fully featured and highly configurable SFTP server with optional FTP/S and WebDAV support, written in Go. Several storage backends are supporte

Jan 9, 2023

A RTP - WebRTC broadcast server for Project Lightspeed.

Project Lightspeed WebRTC A RTP - WebRTC server based on Pion written in Go. This server accepts RTP packets on port 65535 and broadcasts them via We

Sep 1, 2022

Heart πŸ’œA high performance Lua web server with a simple, powerful API

Heart πŸ’œA high performance Lua web server with a simple, powerful API

Heart πŸ’œ A high performance Lua web server with a simple, powerful API. See the full documentation here. Overview Heart combines Go's fasthttp with Lu

Aug 31, 2022

The Galène videoconferencing server

The Galène videoconferencing server

Dec 28, 2022

A push notification server written in Go (Golang).

A push notification server written in Go (Golang).

A push notification micro server using Gin framework written in Go (Golang)

Jan 9, 2023
Comments
  • Some questions to start using it

    Some questions to start using it

    Hi and thank you for your great job !

    I have some questions about it :

    • Your exemples are very light, is there something to do to have logs when a subscribe or a publish is made ?
    • Is it possible to use a database like MySQL to store the subscribers ?
    • Did you made the 5.3.1 part of the W3C article, where the hub must confirm a subscribe by receiving a GET request with the hub.challenge issued during the subscribe ? I can't make it work.
    • The W3C article is not very clear about the parameters to send for publishing, do you use, in addition to hub.mode=publish, the parameter hub.topic or hub.url?
    • I have an error when a subscribe request is made and a hub.lease_seconds param is send by the subscriber to the hub : 'hub.lease_seconds' expected type 'int', got unconvertible type '[]string', value: '[60]'

    Thanks again !

  • Subscriber/client implemtnatino?

    Subscriber/client implemtnatino?

    Hi @tystuyfzand πŸ‘‹

    Sorry to reach out to you like this, you seem to have no other contact methods πŸ˜…

    I really like your implementation of WebSub here -- I believe it implements both a Hub and Publisher right?

    I'm considering using your package/library, however I cannot find a good implementation of a Subscriber/client -- Do you know of any? Or perhaps would you help me build one? I really like your design principles here πŸ˜‰

    Kind regards

    James

A very simple Golang server handling basic GET and POST requests

GOLANG SERVER INTRO As a true Blockchain enthusiast, I had to learn Solidity and Golang to participate to several projects. This repository consists o

Nov 17, 2021
Static Content Web Server

Static Content Web Server The main purpose of the project is to develop static server that can be used with modern javascript frameworks (React, vue.j

Dec 17, 2021
a simple http server as replacement of python -m http.server

ser a simple http server as replacement of python -m http.server

Dec 5, 2022
OpenAPI specs for your Go server, generated at server runtime. No CLI, no code generation, and no HTTP

Overview "oas" is short for "OpenAPI Spec". Go package for generating OpenAPI docs at runtime. Non-features: No code generation. No CLI. No magic comm

Dec 3, 2021
A Language Server Protocol (LSP) server for Jsonnet

Jsonnet Language Server A Language Server Protocol (LSP) server for Jsonnet. Features Jump to definition self-support.mp4 dollar-support.mp4 Error/War

Dec 14, 2022
Go web server - A web server that can accept a GET request and serve a response.

go_web_server A web server that can accept a GET request and serve a response. Go is a great language for creating simple yet efficient web servers an

Jan 3, 2022
:tophat: Small self-contained pure-Go web server with Lua, Markdown, HTTP/2, QUIC, Redis and PostgreSQL support
:tophat: Small self-contained pure-Go web server with Lua, Markdown, HTTP/2, QUIC, Redis and PostgreSQL support

Web server with built-in support for QUIC, HTTP/2, Lua, Markdown, Pongo2, HyperApp, Amber, Sass(SCSS), GCSS, JSX, BoltDB (built-in, stores the databas

Jan 1, 2023
Fast, multi-platform web server with automatic HTTPS
Fast, multi-platform web server with automatic HTTPS

a project Every site on HTTPS Caddy is an extensible server platform that uses TLS by default. Releases Β· Documentation Β· Get Help Menu Features Insta

Jan 1, 2023
A simple SHOUTcast server.

DudelDu DudelDu is a simple audio/video streaming server using the SHOUTcast protocol. Features Supports various streaming clients: VLC, ServeStream,

Nov 20, 2022