Regaez / grav-plugin-api

A REST API plugin for GravCMS
MIT License
27 stars 6 forks source link

feat: add custom API events #39

Closed Regaez closed 4 years ago

Regaez commented 5 years ago

The API could trigger custom events, such as:

... etc

These could be very useful to allow easy communication back to Grav\Plugin\GravApi, in order to trigger some specific plugin actions after an Api event. Perhaps even for external plugins to hook into, such as the Admin plugin exposes, to allow 3rd party extensions over the API.

For example, onApiPageGet might be a useful hook if you wanted to add a tracking plugin to monitor API traffic, or maybe onApiPageUpdate if you want to bust the cache when a page is updated.

At the moment, the API handles the request and then the plugin immediately calls exit, stopping any further execution by Grav. This would probably need to change, to allow any other plugins to tap into the custom events.

Regaez commented 4 years ago

Additionally, we should also create a new docs/EVENTS.md file afterwards that explains the presence of custom events. This should include a list each of the event and its parameters so that others can easily refer to this if they want to develop some third party plugins which integrate with the API.