WSO2 The API Gateway has a default mediation flow, which get is executed in each API invoke. If you have a requirement to do any additional/You can do additional custom mediation for the messages received on in the API Gateway , that can be achieved throgh by extending the mediation flow of the messages. This guide section explains how the mediation flow of a message being received on the WSO2 API Gateway (API Manager) can be extended to perform a custom set of mediations. Mediation extensions can be applied at two levels.
- Global Extensions - This will be applied for all APIs.
- Per API Extensions - This extension will only be applied for an intended API.
...
.
You can apply mediation extensions in two stages as follows:
- Global Extensions : Apply to all APIs
- Per-API Extensions : Apply only to an intended API
Creating global extensions
Anchor | ||||
---|---|---|---|---|
|
An Extension is provided as a synapse mediation sequence. Creating You create mediation extensions is done through creating a new sequence. The difference between a Global Extension global extension and a Per per-API Extension extension is simply in the name given to the particular sequence that you use to create it.
Following Given below is the sequence naming pattern of the sequence to follow when creating a global extension sequence
...
.
WSO2AM--Ext--<DIRECTION>
The The <DIRECTION>
could either can be 'either In
' or 'Out
'. When the direction of the sequence is 'In
', the extension will be is triggered on the in-flow (request path). When it the direction of the sequence is 'Out
', the extension will be is triggered on the outthe out-flow (response path).
Following is an example synapse configuration of a Global Extension global extension sequence.
Code Block | ||||
---|---|---|---|---|
| ||||
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In"> <log level="custom"> <property name="TRACE" value="Global Mediation Extension"/> </log> </sequence> |
To see this at workTo test it, copy this content into code to an xml XML file (e.g., global_ext.xml) and save it in the <API_Gateway>/repository/deployment/server/synapse-configs/default/sequences directory. The above sequence prints a log message on the console on every API invocation.
...