Is there any pre/post dispatch events for the Magento 2 web API (REST/SOAP) ?
3 Answers
There are no events in Magento 2 web APIs, but it is possible to extend any public method in the system using befor/after/around plugins. Also see why it is better to use plugins instead of observers.
-
I was also thinking the same, but just wanted to be sure before creating a plugin for this Commented Jan 15, 2016 at 6:45
-
Just wanted to clarify, that you want to extend something in the framework itself, not just add custom field to the API request/response, right? If just add new field then extension attributes is the way to go. Commented Jan 15, 2016 at 7:45
-
I just wanted to log the requests sent to the Web API of magento REST or SOAP for audit purposes Commented Jan 15, 2016 at 9:14
-
-
Already implemented and it is working as expected Thanks for you answer!! Commented Jan 15, 2016 at 14:37
I don't know maybe this is a dirty way, override this class
Magento\Webapi\Controller\Rest\Router::match()