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 { if len(ext) != 2 {
continue continue
} }
if ext[1] == "so" { if ext[1] != "so" {
plug, err := plg.Open("plugins/"+f.Name()) continue
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())
} }
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 core.Plugins = allPlugins
fmt.Printf("Loaded %v Plugins\n", len(allPlugins)) fmt.Printf("Loaded %v Plugins\n", len(allPlugins))

View File

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

Binary file not shown.