2017-10-25 11:33:19 -05:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
2017-08-16 17:23:38 -05:00
|
|
|
package plugin
|
|
|
|
|
|
2017-08-28 11:27:18 -05:00
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
2017-11-02 16:23:41 -05:00
|
|
|
// Hooks represents an object that handles events for a plugin. Methods are likely to be added over
|
|
|
|
|
// time, and plugins are not expected to implement all of them. Instead, plugins are expected to
|
|
|
|
|
// implement a subset of them and pass an instance to plugin/rpcplugin.Main, which will take over
|
|
|
|
|
// execution of the process and add default behaviors for missing hooks.
|
2017-08-16 17:23:38 -05:00
|
|
|
type Hooks interface {
|
2017-11-02 16:23:41 -05:00
|
|
|
// OnActivate is invoked when the plugin is activated. Implementations will usually want to save
|
|
|
|
|
// the api argument for later use. Loading configuration for the first time is also a commonly
|
|
|
|
|
// done here.
|
2017-08-16 17:23:38 -05:00
|
|
|
OnActivate(API) error
|
|
|
|
|
|
|
|
|
|
// OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to
|
|
|
|
|
// use the API, and the plugin will be terminated shortly after this invocation.
|
|
|
|
|
OnDeactivate() error
|
2017-08-28 11:27:18 -05:00
|
|
|
|
2017-09-11 10:02:02 -05:00
|
|
|
// OnConfigurationChange is invoked when configuration changes may have been made.
|
|
|
|
|
OnConfigurationChange() error
|
|
|
|
|
|
2017-08-28 11:27:18 -05:00
|
|
|
// ServeHTTP allows the plugin to implement the http.Handler interface. Requests destined for
|
|
|
|
|
// the /plugins/{id} path will be routed to the plugin.
|
|
|
|
|
//
|
|
|
|
|
// The Mattermost-User-Id header will be present if (and only if) the request is by an
|
|
|
|
|
// authenticated user.
|
|
|
|
|
ServeHTTP(http.ResponseWriter, *http.Request)
|
2017-08-16 17:23:38 -05:00
|
|
|
}
|