Plugin
Plugins are supported on gAPI.
These plugins must be writen in Golang and are only supportend on Unix.
Currently, it is supported these types of plugins:
- BeforeRequestPlugin
Build a plugin
-
A plugin must use package main.
-
To build the plugin for usage, run this command:
go build -buildmode=plugin -o <plugin_name>.so <plugin_name>.go
Types
BeforeRequestPlugin
-
These plugins are run before each request to a microservice on gAPI.
-
When a plugin returns an error, the request will fail and stop.
-
The following methods must be implemented:
func (g beforeRequestEntryPlugin) Call(c *routing.Context) error
Activate a plugin on gAPI
Currently, to activate a plugin on gAPI you must add the following configuration to gAPI.json config:
"Plugins": {
"Location": "./custom_plugins",
"BeforeRequest": ["BeforeRequestPlugin"]
}
Params:
- Location - where plugins are stored
- BeforeRequest - List of BeforeRequestPlugin type plugins