Search code examples
cuba-platform

Add interceptor to default REST API V2


I want to provide a versioned REST API to handle API changes by changing the domain model. In default case I want to use the default REST API of the cuba platform. If I have have a version information in the mime type or in the json data I want to call a service which manipulates the incoming REST data to be compatible to the domain model.

What is the good solution to do that?


Solution

  • Thanks for raising an important issue.

    Right now the platform doesn't give any tools for writing such interceptors, but have plans to implement it in one of next releases (probably in 6.5). We'll add some kind of pre/post handlers for REST API that will enable transformation of incoming entity name, parameters and JSON before and after invocation of generic REST API methods. The handlers will also receive a version number passed from clients in a header or parameter.