Documentation ¶
Index ¶
- type ClientID
- type ClientSecret
- type Handler
- func (h *Handler) Close()
- func (h *Handler) Listen(clientID ClientID) (<-chan json.RawMessage, error)
- func (h *Handler) ListenConnections() <-chan ClientID
- func (h *Handler) Send(clientID ClientID, eventName string, payload interface{}) error
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientID ¶
type ClientID [clientIDLength]byte
func ClientIDFromString ¶
func NewClientID ¶
func (ClientID) MarshalJSON ¶
func (ClientID) MarshalText ¶
type ClientSecret ¶
type ClientSecret [clientSecretLength]byte
func ClientSecretFromString ¶
func ClientSecretFromString(s string) (ClientSecret, error)
func (ClientSecret) String ¶
func (c ClientSecret) String() string
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a HTTP handler that manages bidirectional connections on top of HTTP and SSE.
The client-to-server messages are sent over regular HTTP requests, and the server-to-client messages are dispatched via server sent events.
This handler handles two routes under a given prefix: 1. POST /prefix/command for client sent messages 2. GET /api/events/{ID} for server sent events
Connection steps: 1. Client sends initial POST to open connection with a client ID (how do we prevent takeovers?). 2. Server sends back SSE endpoint URL. 3. Client creates EventSource and when the connection is open, confirms to the server.
func NewHandler ¶
func (*Handler) Listen ¶
func (h *Handler) Listen(clientID ClientID) (<-chan json.RawMessage, error)
func (*Handler) ListenConnections ¶
Click to show internal directories.
Click to hide internal directories.