Documentation
¶
Overview ¶
Package sse implements Server-Sent Events parsing and writing per the WHATWG spec (https://html.spec.whatwg.org/multipage/server-sent-events.html).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Type string // "event:" field; empty string means unnamed event
Data string // "data:" field; multiple data lines joined with "\n"
ID string // "id:" field
Retry int // "retry:" field in milliseconds; 0 means not set
}
Event represents a single Server-Sent Event.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader parses Server-Sent Events from a byte stream.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes Server-Sent Events to an HTTP response.
func NewWriter ¶
func NewWriter(w http.ResponseWriter) (*Writer, error)
NewWriter creates a Writer that writes SSE to w. It returns an error if w does not implement http.Flusher.
func (*Writer) SetHeaders ¶
func (w *Writer) SetHeaders()
SetHeaders sets the standard SSE response headers.
func (*Writer) WriteEvent ¶
WriteEvent writes a single event in SSE wire format and flushes. Returns an error if the underlying writer fails.
Click to show internal directories.
Click to hide internal directories.