Skip to main content

Server-Sent-Events (SSE)

Server-sent events can be used in different ways. This example here is per connection - per handler SSE. If your requirements need more complex broadcasting logic see https://github.com/r3labs/sse library.

Using SSE

Server

cookbook/sse/simple/server.go
loading...

Event structure and Marshal method

cookbook/sse/simple/serversentevent.go
loading...

HTML serving SSE

cookbook/sse/simple/index.html
loading...

Using 3rd party library r3labs/sse to broadcast events

Server

cookbook/sse/broadcast/server.go
loading...

HTML serving SSE

cookbook/sse/broadcast/index.html
loading...