Interceptors - Modifying All Service Responses
One Plugin for Multiple API Calls
In some cases, you might want to modify all the responses from a certain type of service.
For example, if all patients show their date of birth, but you would like to show their age.
You could either subscribe to each API that returns a patient entity in its response, or you could use the ADAPT_ENTITY
option instead.
Subscribing with ADAPT_ENTITY
To subscribe to with ADAPT_ENTITY
, see the following article.
Use the interceptions.type
to pass ADAPT_ENTITY
parameter and in interceptions.entityTypeName
pass the name of the entity you would like to intercept.
For example passing the patient
entity name will result in BioT hooking your lambda to the following API calls:
PATCH/organization/v1/users/patients/{id}
GET/organization/v1/users/patients
DELETE/organization/v1/users/patients/{id}
POST/organization/v1/users/patients
POST/organization/v1/users/patients/{id}/enabled-state/{state}
GET/organization/v1/users/patients/{id}
GET/organization/v1/users/patients/self
As seen in POST_REQUEST
, the code will receive the original API response body and is expected to return it, modified or not, as the lambda response.
Call sequence
Note that the
ADAPT_ENTITY
callbacks are made afterPRE_REQUEST
but beforePOST_REQUEST
callbacks. This means that changes made duringPOST_REQUEST
will override theADAPT_ENTITY
changes.
Updated 10 months ago