From cd20fae309a31a1672bf66b9d05de213eb0e2b3f Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Mon, 25 Jun 2018 21:01:10 -0700 Subject: [PATCH] Created Statup Plugins (markdown) --- Statup-Plugins.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Statup-Plugins.md diff --git a/Statup-Plugins.md b/Statup-Plugins.md new file mode 100644 index 0000000..e8b95be --- /dev/null +++ b/Statup-Plugins.md @@ -0,0 +1,34 @@ +Since Statup is built in Go Language we can use the go plugin feature to create dynamic plugins that run on load. Statup has an event anytime anything happens, you can create your own plugins and do any type of function. + +## Plugin Interface +```go +type PluginActions interface { + GetInfo() Info + GetForm() string + SetInfo(map[string]interface{}) Info + Routes() []Routing + 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{}) + OnShutdown() + OnLoad(sqlbuilder.Database) +} +``` + +## Example of an Event +Knowing what happens during an event is important for your plugin. For example, lets have an event that echo something when a service has a Failure status being issued. +```go +func OnFailure(service map[string]interface{}) { + fmt.Println("oh no! an event is failing right now! do something!") + fmt.Println(service) +} +``` \ No newline at end of file