Documentation ¶
Overview ¶
Package handler contains types for interacting with the broker implementation via HTTP.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Broker ¶
type Broker interface { Status() *broker.Status Publish(string, string, broker.Message) error NewClient(string, string) (*broker.Client, error) RemoveClient(string, string) }
The Broker interface defines methods the HTTP handlers use to perform operations against the broker from HTTP requests.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
The Handler type contains methods for handling inbound HTTP requests to the broker.
func (*Handler) Publish ¶
func (h *Handler) Publish(w http.ResponseWriter, r *http.Request)
Publish handles an incoming HTTP POST request and writes a message to the broker. Returns a 400 if invalid JSON has been provided.
func (*Handler) Status ¶
func (h *Handler) Status(w http.ResponseWriter, r *http.Request)
Status handles an incoming HTTP GET request that returns the current status of the node and the gossip member list
func (*Handler) Subscribe ¶
func (h *Handler) Subscribe(w http.ResponseWriter, r *http.Request)
Subscribe handles an incoming HTTP GET request and starts an event-stream with the client. The connection remains open while events are read from the broker. Events are written sequentially in 'text/event-stream' format. When the client disconnects, they're removed from the broker.