Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The API Gateway has a default mediation flow, which you can extend by adding custom mediation sequences. You create a custom a custom mediation sequences either sequences either manually or using WSO2 tooling support (i.e., WSO2 Developer Studio), and then engage it per API or globally to it per API or globally to all APIs.    

Creating per-API extensions

The recommended way to  to engage a mediation extension sequence per API is to upload an XML file through the registry and then engage it using the API Publisher. The following tutorial shows how to do this: Engage a Custom Mediation Flow.

Alternatively, you can name the mediation XML file in the pattern pattern <API_NAME>:v<VERSION>--<DIRECTION> and save it directly in the following location:

  • In the single-tenant mode, save the XML file in the <APIM_HOME>/repository/deployment/server/synapse-configs/default/sequences directory.
  • In the multi-tenant mode, save the XML file in the tenant's synapse sequence folder. For example, if tenant id is 1, then save it in <API_Gateway>/repository/tenants/1/synapse-configs/default/sequences folder. 

In the naming pattern, the <DIRECTION> can be In or Out. When it is In, the extension is triggered on the in-flow (request path) and when it is is Out, the extension is triggered on the out-flow (response path). To  To change the default fault sequence, you can either modify the default sequence or write a custom fault sequence and engage it to APIs through the API Publisher. 

Creating global extensions

You can also engage mediation extension sequences to all APIs in the API Manager at once. To do that, simply create the XML with the naming pattern WSO2AM--Ext--<DIRECTION> and  and save it in the <APIM_HOME>/repository/deployment/server/synapse-configs/default/sequences directory.