route based on differnt end point

i want to route single proxy to two different backend server let say

proxy created named as "TE-Route-Demo" with basepath /v1/mockroute with backend as mocktarget

then i create a another target endpoint as "bin" with http tag with backend as httpbin

so can you help me how to route based on path suffix like

when i hit this url https://rohanjangid-eval-test.apigee.net/v1/mock-routee it will route to mocktarget backend and

when i hit this url https://rohanjangid-eval-test.apigee.net/v1/httpbin it will route to httpbin backend

Solved Solved
0 3 229
1 ACCEPTED SOLUTION

Hi Rohan,

You have two ways to achieve this.

1. Create two route rules in the proxy endpoint, and check the base path in the condition. Then create two target endpoints e.g. names: mock-target & http-bin-target.

2. Create a single target endpoint, write a java script, and based on the path suffix, set target.url variable and use it in the target endpoint.

Out of the above two ways, I would go for 1st way as it makes the proxy very configurable.

I hope this would help.

View solution in original post

3 REPLIES 3

Hi Rohan,

You have two ways to achieve this.

1. Create two route rules in the proxy endpoint, and check the base path in the condition. Then create two target endpoints e.g. names: mock-target & http-bin-target.

2. Create a single target endpoint, write a java script, and based on the path suffix, set target.url variable and use it in the target endpoint.

Out of the above two ways, I would go for 1st way as it makes the proxy very configurable.

I hope this would help.

hy vivek thanks for the response as i added two target endpoint(backend) and two proxy endpoint

can you please let me know what is the route condition for that

11061-route.jpg

Hi Rohan,

Two target endpoints are fine but I don't think you need to proxy endpoints. Just create flows in the single proxy endpoitns.

Then in the proxy endpoint xml, add the below configuration

<RouteRule name="bin">
<Condition>proxy.pathsuffix = "/httpbin"</Condition>
<TargetEndpoint>bin</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>