Reputation: 12037
I have several APIs behind a WSO2 instance, each with it's own context ("/api-1/", "/api-2/", ...) I'd like to add this context string dynamically to an Http header (without hardcoding it on a per-API basis).
So, for example:
<sequence name="WSO2AM--Ext--In">
<header name="X-Script-Name"
scope="transport" expression="get-property('', '')"/>
</sequence>
Is there an expression that I can use to achieve this? Or should I resort to creating a per-API mediator to include it?
Edit:
I have tried using the url regex, expecting it to treat {context}
as part of the uri variables, but it doesn't seem to do it:
<header name="X-Script-Name" scope="transport" expression="uri.var.context"/>
Upvotes: 0
Views: 469
Reputation: 9702
Did you define "uri.var.context" before? It is not inbuilt variable to be used. You can read the "To" header and apply the string manipulation using xpath, so you can get the context.
Edit;
You can read API metadata(context,version etc..) from jwt token.Get the jwt token from transport header and manipulate it.
Upvotes: 1