go-sse: github.com/euskadi31/go-sse Index | Files

package sse

import "github.com/euskadi31/go-sse"

Index

Package Files

marshaler.go message.go response.go retry.go server.go

Constants

const LastEventID = "Last-Event-ID"

LastEventID header

Variables

var ErrDurationEmpty = errors.New("duration is empty")

ErrDurationEmpty message

var ErrMessageEmpty = errors.New("message is empty")

ErrMessageEmpty message

type EventMarshaler Uses

type EventMarshaler interface {
    MarshalEvent() ([]byte, error)
}

EventMarshaler interface

type HandlerFunc Uses

type HandlerFunc func(ResponseWriter, *http.Request)

HandlerFunc type

func (HandlerFunc) ServeHTTP Uses

func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *http.Request)

ServeHTTP calls f(w, r).

type MessageEvent Uses

type MessageEvent struct {
    ID    string
    Event string
    Data  []byte
}

MessageEvent struct

func (MessageEvent) MarshalEvent Uses

func (m MessageEvent) MarshalEvent() ([]byte, error)

MarshalEvent implements the encoding.TextMarshaler interface.

type ResponseWriter Uses

type ResponseWriter struct {
    http.ResponseWriter
    // contains filtered or unexported fields
}

ResponseWriter struct

func (*ResponseWriter) Send Uses

func (rw *ResponseWriter) Send(data EventMarshaler)

Send data to client

type Retry Uses

type Retry struct {
    Duration time.Duration
}

Retry struct

func (Retry) MarshalEvent Uses

func (r Retry) MarshalEvent() ([]byte, error)

MarshalEvent implements the EventMarshaler interface.

type Server Uses

type Server struct {
    // contains filtered or unexported fields
}

Server struct

func NewServer Uses

func NewServer(handle HandlerFunc) *Server

NewServer constructor

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request)

func (*Server) SetRetry Uses

func (s *Server) SetRetry(duration time.Duration)

SetRetry duration

Package sse imports 6 packages (graph). Updated 2020-11-23. Refresh now. Tools for package owners.