Documentation ¶
Overview ¶
Package http - Contains HTTP and websocket handlers for exposing curators to clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidDocument = errors.New("invalid document structure") ErrInvalidUserID = errors.New("invalid user ID") )
Common errors for the http package.
Functions ¶
func WebsocketHandler ¶
func WebsocketHandler( finder curator.Type, timeout time.Duration, logger log.Modular, stats metrics.Aggregator, ) func(ws *websocket.Conn)
WebsocketHandler - Returns a websocket handler that routes new websockets to a curator. Use this with an HTTP server with the "golang.org/x/net/websocket" package.
Types ¶
type LeapSocketClientMessage ¶ added in v0.7.0
type LeapSocketClientMessage struct { Command string `json:"command"` Transform *text.OTransform `json:"transform,omitempty"` Position *int64 `json:"position,omitempty"` Message string `json:"message,omitempty"` }
LeapSocketClientMessage - A structure that defines a message format to expect from clients connected to a text model. Commands can currently be 'submit' (submit a transform to a bound document), or 'update' (submit an update to the users cursor position).
type LeapSocketServerMessage ¶ added in v0.7.0
type LeapSocketServerMessage struct { Type string `json:"response_type"` Transforms []text.OTransform `json:"transforms,omitempty"` Updates []binder.ClientUpdate `json:"user_updates,omitempty"` Version int `json:"version,omitempty"` Error string `json:"error,omitempty"` }
LeapSocketServerMessage - A structure that defines a response message from a text model to a client. Type can be 'transforms' (continuous delivery), 'correction' (actual version of a submitted transform), 'update' (an update to a users status) or 'error' (an error message to display to the client).