For example I have https://apibaas-trial.apigee.net/shebababu92/sandbox/messengers
and
https://apibaas-trial.apigee.net/shebababu92/sandbox/newmessengers.
I need to call https://apibaas-trial.apigee.net/shebababu92/sandbox/messengers/message1 or https://apibaas-trial.apigee.net/shebababu92/sandbox/messengers/message2 or
https://apibaas-trial.apigee.net/shebababu92/sandbox/newmessengers/message1 or
https://apibaas-trial.apigee.net/shebababu92/sandbox/newmessengers/message2
How can I use Java Regex in this case?
What is the condition that I should use?
Solved! Go to Solution.
One way to do it is to have multiple targets, each with a different target endpoint. Then you'd have RouteRules, each with a distinct condition, that route to each of your different targets.
<RouteRule name='rule1'> <Condition>(whatever you like here</Condition> <Target>target1</Target> </RouteRule> <RouteRule name='rule2'> <Condition>(whatever you like here</Condition> <Target>target2</Target> </RouteRule> ...
This seems to be heavyweight approach to the problem , especially if you've got numerous backend target URLs.
An alternative is to set the target.url variable within a JS callout. This must be done on the Target Request flow. The JS might look like:
var candidateUrls = [ 'https://apibaas-trial.apigee.net/shebababu92/sandbox/messengers', 'https://apibaas-trial.apigee.net/shebababu92/sandbox/newmessengers', ]; if (some condition here) { context.setVariable('target.url', candidateUrls[0]); } else { context.setVariable('target.url', candidateUrls[1]); }
One way to do it is to have multiple targets, each with a different target endpoint. Then you'd have RouteRules, each with a distinct condition, that route to each of your different targets.
<RouteRule name='rule1'> <Condition>(whatever you like here</Condition> <Target>target1</Target> </RouteRule> <RouteRule name='rule2'> <Condition>(whatever you like here</Condition> <Target>target2</Target> </RouteRule> ...
This seems to be heavyweight approach to the problem , especially if you've got numerous backend target URLs.
An alternative is to set the target.url variable within a JS callout. This must be done on the Target Request flow. The JS might look like:
var candidateUrls = [ 'https://apibaas-trial.apigee.net/shebababu92/sandbox/messengers', 'https://apibaas-trial.apigee.net/shebababu92/sandbox/newmessengers', ]; if (some condition here) { context.setVariable('target.url', candidateUrls[0]); } else { context.setVariable('target.url', candidateUrls[1]); }
Thank you so much .If I am using JS what condition I should give in Route rule?