Hugo preview mode. Update Plugin registration.
Former-commit-id: b6c33f0ae36e7caa8cf813eeb6f8fdeb554659e9 [formerly 4d62c13f0b7e5b7610a0c9037d646c2005e9ba88] [formerly 1e9ded0427d81084c92a68d5eddb8c7620fb189c [formerly ae8eaf96c43e252245bead932e43685c542d85e1]] Former-commit-id: 76699219a6d176777f4478eab5141bba5a613a17 [formerly bb698073213359bebce84ea196b30e9467f448c0] Former-commit-id: 538927b5a6fad024eb062cf746068372c384b883
This commit is contained in:
@@ -175,6 +175,8 @@ type Rule struct {
|
||||
Regexp *Regexp `json:"regexp"`
|
||||
}
|
||||
|
||||
type PluginHandler func(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
|
||||
// Regexp is a regular expression wrapper around native regexp.
|
||||
type Regexp struct {
|
||||
Raw string `json:"raw"`
|
||||
@@ -185,8 +187,10 @@ type Plugin struct {
|
||||
JavaScript string
|
||||
CommandEvents []string
|
||||
Permissions []Permission
|
||||
Handler PluginHandler
|
||||
Options interface{}
|
||||
Handlers map[string]PluginHandler `json:"-"`
|
||||
BeforeAPI PluginHandler `json:"-"`
|
||||
AfterAPI PluginHandler `json:"-"`
|
||||
}
|
||||
|
||||
type Permission struct {
|
||||
@@ -194,13 +198,6 @@ type Permission struct {
|
||||
Value bool
|
||||
}
|
||||
|
||||
type PluginHandler interface {
|
||||
// If the Plugin returns (0, nil), the executation of File Manager will procced as usual.
|
||||
// Otherwise it will stop.
|
||||
Before(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
After(c *RequestContext, w http.ResponseWriter, r *http.Request) (int, error)
|
||||
}
|
||||
|
||||
func RegisterPlugin(name string, plugin Plugin) {
|
||||
if _, ok := plugins[name]; ok {
|
||||
panic(name + " plugin is already registred")
|
||||
|
||||
Reference in New Issue
Block a user