github.com/coincircle/mattermost-server@v4.8.1-0.20180321182714-9d701c704416+incompatible/plugin/hooks.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package plugin
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"github.com/mattermost/mattermost-server/model"
    10  )
    11  
    12  // Methods from the Hooks interface can be used by a plugin to respond to events. Methods are likely
    13  // to be added over time, and plugins are not expected to implement all of them. Instead, plugins
    14  // are expected to implement a subset of them and pass an instance to plugin/rpcplugin.Main, which
    15  // will take over execution of the process and add default behaviors for missing hooks.
    16  type Hooks interface {
    17  	// OnActivate is invoked when the plugin is activated. Implementations will usually want to save
    18  	// the api argument for later use. Loading configuration for the first time is also a commonly
    19  	// done here.
    20  	OnActivate(API) error
    21  
    22  	// OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to
    23  	// use the API, and the plugin will be terminated shortly after this invocation.
    24  	OnDeactivate() error
    25  
    26  	// OnConfigurationChange is invoked when configuration changes may have been made.
    27  	OnConfigurationChange() error
    28  
    29  	// ServeHTTP allows the plugin to implement the http.Handler interface. Requests destined for
    30  	// the /plugins/{id} path will be routed to the plugin.
    31  	//
    32  	// The Mattermost-User-Id header will be present if (and only if) the request is by an
    33  	// authenticated user.
    34  	ServeHTTP(http.ResponseWriter, *http.Request)
    35  
    36  	// ExecuteCommand executes a command that has been previously registered via the RegisterCommand
    37  	// API.
    38  	ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError)
    39  }