Reputation: 409
I have created an API in WSO2 API Manager and I want to add a custom header when API gateway receive the request and set the custom header to the API and pass it to back end. for example when API gateway receive the request for every request of this type adds "My-Header : xxxxx" to the request and pass it to back end.
How is it possible ?
Upvotes: 2
Views: 3682
Reputation: 621
You can achieve this via various methods as mentioned below.
Publisher portal: If you want to add a custom header along with the request itself, you can add it as follows in the publisher portal.
Via custom mediation: If you want to add the custom header in the gateway component, you can use either a custom sequence built using a header mediator. This is appropriate to be used if your requirement is simple and doesn't have any complicated logic to be addressed. If you want to add the custom header to a specific API, then you can add the custom mediation only to that API. In case if you want to add it to all the APIs as a global solution, then you can add it as a global sequence.
Via custom handler: If you have a complicated requirement in adding the custom header and if you want to add the header in the gateway component, you can use a custom handler to achieve this.
Upvotes: 5
Reputation: 56
You can add an in-sequnce as below:
<sequence name="test" xmlns="http://ws.apache.org/ns/synapse">
<property name="<NAME>" value="<VALUE>" scope="transport"/>
<property name="<NAME>" value="<VALUE>" scope="transport"/>
</sequence>
Upvotes: 2
Reputation: 1017
You can use a custom sequence or header mediator for this purpose.
From a long term perspective, you can write a custom handler for your specific goal.
Upvotes: 3