How to solve the conditional routing implementation based on query parameter to backend services?

Not applicable
 
Solved Solved
0 2 904
1 ACCEPTED SOLUTION

@A.Anu Manasa,

You can use the <RouteRule> tag to direct a request to a target based on a condition. Please read the section "Conditional targets" in this link for more details including an example for routing based on header.

Here's a sample code that shows how to do this using query parameter:

<RouteRule name="Route1">
  <Condition>request.queryparam.routeTo = "TargetEndpoint1"</Condition>
  <TargetEndpoint>TargetEndpoint1</TargetEndpoint>
</RouteRule>
<RouteRule name="Route2">
  <Condition>request.queryparam.routeTo = "TargetEndpoint2"</Condition>
  <TargetEndpoint>TargetEndpoint2</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
 <TargetEndpoint>TargetEndpointDefault</TargetEndpoint>
</RouteRule>

Regards,

Amar

View solution in original post

2 REPLIES 2

@A.Anu Manasa,

You can use the <RouteRule> tag to direct a request to a target based on a condition. Please read the section "Conditional targets" in this link for more details including an example for routing based on header.

Here's a sample code that shows how to do this using query parameter:

<RouteRule name="Route1">
  <Condition>request.queryparam.routeTo = "TargetEndpoint1"</Condition>
  <TargetEndpoint>TargetEndpoint1</TargetEndpoint>
</RouteRule>
<RouteRule name="Route2">
  <Condition>request.queryparam.routeTo = "TargetEndpoint2"</Condition>
  <TargetEndpoint>TargetEndpoint2</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
 <TargetEndpoint>TargetEndpointDefault</TargetEndpoint>
</RouteRule>

Regards,

Amar

@A.Anu Manasa,

You can use the <RouteRule> tag to direct a request to a target based on a condition. Please read the section "Conditional targets" in this link for more details including an example for routing based on header.

Here's a sample code that shows how to do this using query parameter:

<RouteRule name="Route1">
  <Condition>request.queryparam.routeTo = "TargetEndpoint1"</Condition>
  <TargetEndpoint>TargetEndpoint1</TargetEndpoint>
</RouteRule>
<RouteRule name="Route2">
  <Condition>request.queryparam.routeTo = "TargetEndpoint2"</Condition>
  <TargetEndpoint>TargetEndpoint2</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
 <TargetEndpoint>TargetEndpointDefault</TargetEndpoint>
</RouteRule>

Regards,

Amar