jsse

package
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeEventStream = "text/event-stream"
	MimeTypeJson        = "application/json"
)

Variables

View Source
var SupportedMimeTypes = []string{MimeTypeEventStream, MimeTypeJson}

Functions

func ServeEvents

func ServeEvents(ctx context.Context, opts Options, rw http.ResponseWriter, events <-chan Event) error

Types

type Event

type Event struct {
	ID    string          `json:"id,omitempty"`
	Event string          `json:"event,omitempty"`
	Data  json.RawMessage `json:"data"`
	// contains filtered or unexported fields
}

type HTTPError

type HTTPError struct {
	StatusCode int
	Cause      error
}

func (HTTPError) Error

func (h HTTPError) Error() string

func (HTTPError) Unwrap

func (h HTTPError) Unwrap() error

type Options

type Options struct {
	MimeType           string
	LastEventID        string
	PollMaxWaitTime    time.Duration
	ClientRetryBackoff time.Duration
	PingPeriod         time.Duration
}

func InitOptions

func InitOptions(r *http.Request) Options

func (Options) WithClientRetryBackoff

func (o Options) WithClientRetryBackoff(backoff time.Duration) Options

func (Options) WithPing

func (o Options) WithPing(period time.Duration) Options

Jump to

Keyboard shortcuts

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