I am trying to have a proxy that will make calls to our staging environment if the endpoint is our Apigee test uri is used and to our production endpoint if the production uri is used.
First Question: Is this a bad design pattern to have this routing condition on our production endpoint?
We want this as it will enable us to test the full integration before deploying to production.
We already have a proxy, say:
ourorg-prod.apigee.net/foo
It routes to:
productionbackend.com/foo
However, we would like to have the proxy route:
ourorg-test.apigee.net/foo
To:
stagingbackend.com/foo
I have played around with TargetServers - one of the main issues I have had is trying to get stagingbackend.com/foo (full URI) as the target server. It works if its just stagingbackend.com, but when I try to add the additional portion of the URI it breaks (and therefore I think it probably shouldn't be done this way. Probably designed just for the base uri to the target server).
Help is appreciated
Solved! Go to Solution.
Hi Kevin,
To answer your first question, no this is not a bad pattern at all. You should be able to use the target server configuration for the hostname and port. It sounds like you have that part working. In the target configuration in the proxy, you can configure the path portion:
<HTTPTargetConnection> <LoadBalancer> <Server name="productionbackend"/> </LoadBalancer> <Path>/foo</Path> </HTTPTargetConnection>
Hope this helps!
@kevin12
You can also try conditional route rule so that in the same proxy, you can dynamically route to different endpoints based on a condition:
Here's an example of conditional route rules:
<RouteRule name="test">
<Condition>(environment.name = "test")</Condition>
<HTTPTargetConnection>
<URL>http://test.mydomain.net</URL>
</HTTPTargetConnection>
</RouteRule>
<RouteRule name="prod">
<Condition>(environment.name = "prod")</Condition>
<HTTPTargetConnection>
<URL>http://prod.mydomain.net</URL>
</HTTPTargetConnection>
</RouteRule>
This would work if you have environments in the Apigee Edge named as prod and test. The apiproxy that is deployed to test environment would be routed to the test endpoint and likewise for prod.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |