/sseserver

Server to stream a JSON file over Server-Sent-Events (SSE) to a client/browser.

Primary LanguageGoApache License 2.0Apache-2.0

sseserver Build Status Go Report Card

Server to stream a JSON file over Server-Sent-Events (SSE) to a client/browser.

Build

Install Go as described: https://golang.org/doc/install and then:

make dev-dependencies
make release 

Test

make test

Run

./sseserver-<os>-<arch> -inputFile <file-to-serve>

Open examples/test_sse.html to receive the SSE events.

Resend file to all connected clients

kill -HUP <PID of sseserver>

Use with Consul Template

The sseserver works nicely when combined with Consul Template to stream information from Consul to clients/browsers.

./consul-template \
-template=/endpoints.ctmpl:/endpoints.json \
-exec='./sseserver -enable-syslog -context /endpoints -input-file /endpoints.json' \
-exec-reload-signal=SIGHUP

Contributors