Plugin Events #
API Events #
Plugins can add new controllers to the Kuzzle API.
These new controllers and actions behave exactly like native API actions.
Controllers declared with the api property of a plugin trigger the same events as native controllers, named after the controller: <controller>:before<Action>, <controller>:after<Action> and <controller>:error<Action>.
The naming templates below, prefixed with the plugin name, only apply to controllers declared with the legacy controllers property.
All calls to plugins API actions trigger two of these three events:
- before the action starts
- after it succeeds
- after it fails
before #
| Arguments | Type | Description |
|---|---|---|
request | KuzzleRequest | The normalized API request |
A before event is triggered before a plugin API request starts.
Naming Template #
The before event name is built using the following template:
<plugin name>/<controller>:before<Action> (legacy controllers property)
plugin name: the plugin's name defined in the manifest filecontroller: API controller nameAction: controller action, camel cased
Example #
| Plugin name | API controller | Action | Before event name |
|---|---|---|---|
plugin | controller | action | plugin/controller:beforeAction |
after #
| Arguments | Type | Description |
|---|---|---|
request | KuzzleRequest | The normalized API request |
An after event is triggered after a plugin API request succeeds.
Naming Template #
The after event name is built using the following template:
<plugin name>/<controller>:after<Action> (legacy controllers property)
plugin name: the plugin's name defined in the manifest filecontroller: API controller nameAction: controller action, camel cased
Example #
| Plugin name | API controller | Action | After event name |
|---|---|---|---|
plugin | controller | action | plugin/controller:afterAction |
error #
| Arguments | Type | Description |
|---|---|---|
request | KuzzleRequest | The normalized API request |
An error event is triggered after a plugin API request fails.
Naming Template #
The error event name is built using the following template:
<plugin name>/<controller>:error<Action> (legacy controllers property)
plugin name: the plugin's name defined in the manifest filecontroller: API controller nameAction: controller action, camel cased
Example #
| Plugin name | API controller | Action | Error event name |
|---|---|---|---|
plugin | controller | action | plugin/controller:errorAction |