statping/plugin/main.go

74 lines
1.3 KiB
Go
Raw Normal View History

2018-06-14 01:19:00 +00:00
package plugin
import (
2018-06-14 06:38:15 +00:00
"fmt"
2018-06-14 01:19:00 +00:00
"net/http"
2018-06-15 04:30:10 +00:00
"upper.io/db.v3/lib/sqlbuilder"
2018-06-14 01:19:00 +00:00
)
2018-06-14 06:38:15 +00:00
//
// STATUP PLUGIN INTERFACE
//
// v0.1
//
// https://statup.io
//
2018-06-19 04:48:25 +00:00
//
// An expandable plugin framework that will still
// work even if there's an update or addition.
//
2018-06-14 06:38:15 +00:00
var (
2018-06-15 04:30:10 +00:00
DB sqlbuilder.Database
2018-06-14 06:38:15 +00:00
)
2018-06-15 04:30:10 +00:00
func SetDatabase(database sqlbuilder.Database) {
2018-06-14 06:38:15 +00:00
DB = database
}
func Throw(err error) {
fmt.Println(err)
}
type PluginInfo struct {
Info Info
PluginActions
}
2018-06-19 06:00:56 +00:00
func (p *PluginInfo) Form() string {
return "okkokokkok"
}
2018-06-14 01:19:00 +00:00
type PluginActions interface {
GetInfo() Info
2018-06-19 06:00:56 +00:00
GetForm() string
2018-06-19 04:48:25 +00:00
SetInfo(map[string]interface{}) Info
2018-06-14 01:19:00 +00:00
Routes() []Routing
2018-06-19 04:48:25 +00:00
OnSave(map[string]interface{})
OnFailure(map[string]interface{})
OnSuccess(map[string]interface{})
OnSettingsSaved(map[string]interface{})
OnNewUser(map[string]interface{})
OnNewService(map[string]interface{})
OnUpdatedService(map[string]interface{})
OnDeletedService(map[string]interface{})
OnInstall(map[string]interface{})
OnUninstall(map[string]interface{})
OnBeforeRequest(map[string]interface{})
OnAfterRequest(map[string]interface{})
2018-06-14 01:19:00 +00:00
OnShutdown()
2018-06-19 04:48:25 +00:00
OnLoad(sqlbuilder.Database)
2018-06-14 01:19:00 +00:00
}
type Routing struct {
URL string
Method string
Handler func(http.ResponseWriter, *http.Request)
}
type Info struct {
Name string
Description string
2018-06-22 04:02:57 +00:00
Form string
2018-06-14 01:19:00 +00:00
}