Documentation ¶
Overview ¶
Package sse provides HTML5 Server-Sent Events for Go.
See http://www.w3.org/TR/eventsource/ for the technical specification
Index ¶
- type Streamer
- func (s *Streamer) BufSize(size uint)
- func (s *Streamer) HandleHTTP(w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
- func (s *Streamer) SendBytes(id, event string, data []byte)
- func (s *Streamer) SendInt(id, event string, data int64)
- func (s *Streamer) SendJSON(id, event string, v interface{}) error
- func (s *Streamer) SendString(id, event, data string)
- func (s *Streamer) SendUint(id, event string, data uint64)
- func (s *Streamer) ServeHTTP(w http.ResponseWriter, _ *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Streamer ¶
type Streamer struct {
// contains filtered or unexported fields
}
Streamer receives events and broadcasts them to all connected clients. Streamer is a http.Handler. Clients making a request to this handler receive a stream of Server-Sent Events, which can be handled via JavaScript. See the linked technical specification for details.
func (*Streamer) HandleHTTP ¶
func (s *Streamer) HandleHTTP(w http.ResponseWriter, _ *http.Request, ps httprouter.Params)
implements Handle for julienschmidt httprouter
func (*Streamer) SendBytes ¶
SendBytes sends an event with the given byte slice interpreted as a string as the data value to all connected clients. If the id or event string is empty, no id / event type is send.
func (*Streamer) SendJSON ¶
SendJSON sends an event with the given data encoded as JSON to all connected clients. If the id or event string is empty, no id / event type is send.
func (*Streamer) SendString ¶
SendString sends an event with the given data string to all connected clients. If the id or event string is empty, no id / event type is send.