upgrades - plugins

pull/10/head
Hunter Long 2018-06-11 03:19:08 -07:00
parent c7ff4ef9ef
commit 15c74bf4d2
3 changed files with 25 additions and 21 deletions

41
main.go
View File

@ -89,27 +89,28 @@ func LoadPlugins() {
if len(ext) != 2 {
continue
}
if ext[1] == "so" {
plug, err := plg.Open("plugins/"+f.Name())
if err != nil {
fmt.Printf("Plugin '%v' could not load correctly.\n", f.Name())
continue
}
symPlugin, err := plug.Lookup("Plugin")
var plugActions plugin.PluginActions
plugActions, ok := symPlugin.(plugin.PluginActions)
if !ok {
fmt.Printf("Plugin '%v' could not load correctly, error: %v\n", f.Name(), "unexpected type from module symbol")
continue
}
//plugin := plugActions.Plugin()
//
//fmt.Println(plugin.OnLoad)
plugActions.OnLoad()
allPlugins = append(allPlugins, plugActions.Plugin())
if ext[1] != "so" {
continue
}
plug, err := plg.Open("plugins/" + f.Name())
if err != nil {
fmt.Printf("Plugin '%v' could not load correctly.\n", f.Name())
continue
}
symPlugin, err := plug.Lookup("Plugin")
var plugActions plugin.PluginActions
plugActions, ok := symPlugin.(plugin.PluginActions)
if !ok {
fmt.Printf("Plugin '%v' could not load correctly, error: %v\n", f.Name(), "unexpected type from module symbol")
continue
}
//plugin := plugActions.Plugin()
//
//fmt.Println(plugin.OnLoad)
plugActions.OnLoad()
//allPlugins = append(allPlugins, plugActions.Plugin())
}
core.Plugins = allPlugins
fmt.Printf("Loaded %v Plugins\n", len(allPlugins))

View File

@ -26,7 +26,7 @@ type Routing struct {
}
type PluginActions interface {
Plugin() *PluginInfo
//Plugin() *PluginInfo
SaveForm()
OnInstall()
OnUninstall()
@ -34,8 +34,11 @@ type PluginActions interface {
OnHit()
OnSettingsSaved()
OnNewUser()
OnNewService()
OnShutdown()
OnLoad()
OnBeforeRequest()
OnAfterRequest()
}
func SetDatabase(db *sql.DB) {

Binary file not shown.