Hugo preview mode. Update Plugin registration.

This commit is contained in:
Henrique Dias
2017-08-08 10:21:25 +01:00
parent a2ed744f24
commit ae8eaf96c4
6 changed files with 79 additions and 18 deletions

View File

@@ -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")