3 [![GoDoc](https://godoc.org/github.com/gin-contrib/sse?status.svg)](https://godoc.org/github.com/gin-contrib/sse)
4 [![Build Status](https://travis-ci.org/gin-contrib/sse.svg)](https://travis-ci.org/gin-contrib/sse)
5 [![codecov](https://codecov.io/gh/gin-contrib/sse/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/sse)
6 [![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/sse)](https://goreportcard.com/report/github.com/gin-contrib/sse)
8 Server-sent events (SSE) is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is [standardized as part of HTML5[1] by the W3C](http://www.w3.org/TR/2009/WD-eventsource-20091029/).
10 - [Read this great SSE introduction by the HTML5Rocks guys](http://www.html5rocks.com/en/tutorials/eventsource/basics/)
11 - [Browser support](http://caniuse.com/#feat=eventsource)
16 import "github.com/gin-contrib/sse"
18 func httpHandler(w http.ResponseWriter, req *http.Request) {
19 // data can be a primitive like a string, an integer or a float
20 sse.Encode(w, sse.Event{
22 Data: "some data\nmore data",
25 // also a complex type, like a map, a struct or a slice
26 sse.Encode(w, sse.Event{
29 Data: map[string]interface{}{
31 "date": time.Now().Unix(),
39 data: some data\\nmore data
43 data: {"content":"hi!","date":1431540810,"user":"manu"}
50 fmt.Println(sse.ContentType)
58 There is a client-side implementation of SSE coming soon.