Documentation ¶
Index ¶
- Variables
- func PrettyJSON(data interface{}) ([]byte, error)
- func WriteJSON(rw http.ResponseWriter, code int, data interface{}, contentType string) error
- type PubsPlugin
- func (p *PubsPlugin) Close() error
- func (p *PubsPlugin) HTTPWebsocketHandler(rw http.ResponseWriter, req *http.Request)
- func (p *PubsPlugin) Info() *plugins.InfoV1
- func (p *PubsPlugin) Initialize(ctx context.Context, errCh chan<- error, srv plugins.ServerV1) error
- func (p *PubsPlugin) MakeHTTPWebhookPublishHandler(router *mux.Router) http.Handler
- func (p *PubsPlugin) MakeHTTPWebhookRegisterHandler(router *mux.Router) http.Handler
- func (p *PubsPlugin) MakeHTTPWebsocketConnectHandler(router *mux.Router) http.Handler
- func (p *PubsPlugin) NumActive() uint64
- func (p *PubsPlugin) OnBeforeDisconnect(c *connection.Connection, err error) error
- func (p *PubsPlugin) OnConnect(c *connection.Connection) error
- func (p *PubsPlugin) OnDisconnect(c *connection.Connection) error
- func (p *PubsPlugin) OnError(c *connection.Connection, err error) error
- func (p *PubsPlugin) OnText(c *connection.Connection, msg []byte) error
- func (p *PubsPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var Register plugins.RegisterPluginV1 = func() plugins.PluginV1 { return &PubsPlugin{} }
Register is the exported registration entry point as loaded by Kopano API to register plugins.
Functions ¶
func PrettyJSON ¶
PrettyJSON marshals the provided data as JSON.
func WriteJSON ¶
func WriteJSON(rw http.ResponseWriter, code int, data interface{}, contentType string) error
WriteJSON marshals the provided data as JSON and writes it to the provided http.ResponseWriter using the provided HTTP status code and content-type. the nature of this function is that it always writes a HTTP response header. Thus it makes no sense to write another header on error. Resulting errors should be logged and the connection should be closes as it is non-functional.
Types ¶
type PubsPlugin ¶
type PubsPlugin struct {
// contains filtered or unexported fields
}
PubsPlugin implements a flexible Webhook system providing a RESTful API to register hooks and a Websocket API for efficient receival.
func (*PubsPlugin) HTTPWebsocketHandler ¶
func (p *PubsPlugin) HTTPWebsocketHandler(rw http.ResponseWriter, req *http.Request)
HTTPWebsocketHandler implements the HTTP handler for stream websocket requests.
func (*PubsPlugin) Info ¶
func (p *PubsPlugin) Info() *plugins.InfoV1
Info returns the accociated plugins plugin.Info.
func (*PubsPlugin) Initialize ¶
func (p *PubsPlugin) Initialize(ctx context.Context, errCh chan<- error, srv plugins.ServerV1) error
Initialize initizalizes the accociated plugin.
func (*PubsPlugin) MakeHTTPWebhookPublishHandler ¶
func (p *PubsPlugin) MakeHTTPWebhookPublishHandler(router *mux.Router) http.Handler
MakeHTTPWebhookPublishHandler creates the HTTP handler for registering webhooks.
func (*PubsPlugin) MakeHTTPWebhookRegisterHandler ¶
func (p *PubsPlugin) MakeHTTPWebhookRegisterHandler(router *mux.Router) http.Handler
MakeHTTPWebhookRegisterHandler implements the HTTP handler for registering webhooks.
func (*PubsPlugin) MakeHTTPWebsocketConnectHandler ¶
func (p *PubsPlugin) MakeHTTPWebsocketConnectHandler(router *mux.Router) http.Handler
MakeHTTPWebsocketConnectHandler createss the HTTP handler for rtm.connect.
func (*PubsPlugin) NumActive ¶
func (p *PubsPlugin) NumActive() uint64
NumActive returns the number of the currently active connections.
func (*PubsPlugin) OnBeforeDisconnect ¶
func (p *PubsPlugin) OnBeforeDisconnect(c *connection.Connection, err error) error
OnBeforeDisconnect is called before a connection is closed. An indication why the connection will be closed is provided with the passed error.
func (*PubsPlugin) OnConnect ¶
func (p *PubsPlugin) OnConnect(c *connection.Connection) error
OnConnect is called for new connections.
func (*PubsPlugin) OnDisconnect ¶
func (p *PubsPlugin) OnDisconnect(c *connection.Connection) error
OnDisconnect is called after a connection has closed.
func (*PubsPlugin) OnError ¶
func (p *PubsPlugin) OnError(c *connection.Connection, err error) error
OnError is called, when the provided connection has encountered an error. The provided error is the error encountered. Any return value other than nil, will result in a close of the connection.
func (*PubsPlugin) OnText ¶
func (p *PubsPlugin) OnText(c *connection.Connection, msg []byte) error
OnText is called when the provided connection received a text message. The message payload is provided as []byte in the msg parameter.
func (*PubsPlugin) ServeHTTP ¶
func (p *PubsPlugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) (bool, error)
ServeHTTP serves HTTP requests.