sse

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

See https://html.spec.whatwg.org/multipage/server-sent-events.html

Index

Constants

View Source
const (
	ContentType = "text/event-stream"
)

Variables

View Source
var (
	ErrHTTPStatusNon200   = errors.New("HTTP status code indicates failure")
	ErrInvalidContentType = errors.New("invalid Content-Type, expected text/event-stream")

	// ErrCloseEventStream is a marker error that can be returned by
	// stream handling func to indicate that the event stream should be
	// closed.
	ErrCloseEventStream = errors.New("close event stream")
)

Functions

func ParseStream added in v0.2.0

func ParseStream(r io.ReadCloser, maxSize int, f func(id, event string, data []byte) error, retryf func(ms uint64)) error

func VerifyResponse added in v0.2.0

func VerifyResponse(resp *http.Response) error

Types

type Msg

type Msg struct {
	IDStr string
	ID    uint64
	Event string
	Data  []byte
}

func (*Msg) Encode

func (msg *Msg) Encode(buf []byte) []byte

func (*Msg) EncodedLen

func (msg *Msg) EncodedLen() int

func (*Msg) String

func (msg *Msg) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL