title: WSO2 API Manager - load balancing with dynamic endpoints
body: <p>I've got an API that uses dynamic endpoints. Now I want it to also do load balancing. I know how to do that using  element, however when using dynamic endpoints in APIM you only manipulate the "To" header. </p>
  
  <p>Below is the mediation sequence used to set the endpoint. Instead of addressing just a single endpoint in each  case, I'd like to be able to loadbalance between 2 servers.</p>
  
  <p>Any thoughts?</p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;sequence name="inSequence_clientEquipmentsAPI_1_2_STG" trace="disable" xmlns="http://ws.apache.org/ns/synapse"&gt;
      &lt;!-- check for healthcheck operation --&gt;
      &lt;filter xpath="get-property('To')='/etc/equipments/client/1.0/healthCheck'"&gt;
          &lt;!-- if healthCheck, directs to healthCheck API (EI)--&gt;
          &lt;then&gt;
              &lt;property name="REST_URL_POSTFIX" scope="axis2" action="remove"/&gt;
              &lt;header name="To" value="http://10.220.160.36:8290/healthCheck/clientEquipments"/&gt;
          &lt;/then&gt;
          &lt;!-- else direct to regular clientEquipment API (EI)--&gt;
          &lt;else&gt;
              &lt;property name="newContext" expression="substring-after(get-property('To'),'/etc')"/&gt;       
              &lt;header name="To" expression="fn:concat('http://10.220.160.36:8290', $ctx:newContext)"/&gt;
          &lt;/else&gt;         
      &lt;/filter&gt;
  &lt;/sequence&gt;
  </code></pre>