alps/plugin.go

25 lines
681 B
Go
Raw Normal View History

2019-12-09 15:02:12 +00:00
package koushin
import (
2019-12-09 16:54:24 +00:00
"html/template"
2019-12-09 15:02:12 +00:00
"github.com/labstack/echo/v4"
)
const pluginDir = "plugins"
2019-12-11 14:24:39 +00:00
// Plugin extends koushin with additional functionality.
2019-12-09 15:02:12 +00:00
type Plugin interface {
2019-12-11 14:24:39 +00:00
// Name should return the plugin name.
2019-12-09 15:02:12 +00:00
Name() string
2019-12-11 14:24:39 +00:00
// LoadTemplate populates t with the plugin's functions and templates.
LoadTemplate(t *template.Template) error
2019-12-11 14:24:39 +00:00
// SetRoutes populates group with the plugin's routes.
SetRoutes(group *echo.Group)
2019-12-11 14:24:39 +00:00
// Inject is called prior to rendering a template. It can extend the
// template data by setting new items in the Extra map.
Inject(name string, data interface{}) error
2019-12-11 14:24:39 +00:00
// Close is called when the plugin is unloaded.
2019-12-09 15:02:12 +00:00
Close() error
}