Submitted by dmitry.wso2.com on Wed, 05/31/2017 - 00:55
Dynamic Endpoint functionality of API Cloud allows you to dynamically pick the backend to which each call is routed based on the call's properties.
For example, suppose you have an API that has two resources /countries and /regions:
And suppose the actual implementation of the functionality is at two different backends. /countries is implemented by first.backend.url and /regions by something.different.url.
Fear not, this is fairly easy to implement with API Cloud. You simply need to select Dynamic Endpoint as the Endpoint Type and upload the In Flow sequence that defines the rules to route the traffic:
In our sample scenario, the In Flow sequence might look similar to this:
<sequence name="dynamic_ep" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="service_ep" value="https//first.backend.url"/>
<property name="service_ep" value="https://something.different.url"/>
<!-- add endpoints as needed -->
<property name="service_ep" value="http://some.default.url"/>
<!--default endpoint if required. However there should be a matching resource-->
<header name="To" expression="get-property('service_ep')"></header>
<property expression="get-property('service_ep')" name="ENDPOINT_ADDRESS"></property>
<!--Please note that "ENDPOINT_ADDRESS" (additional) property is defined here in order to populate
destination address for statistics (API Usage by Destination). -->
You can obviously define more complex rules if needed.
Do you have multiple backend services that need to become a single API? Dynamic Endpoints can get you going!