I have a proxy with a path of /foo and I want my API to have.
/foo/weather <-- will go to weather API
/foo/location <-- will go to geocode API
/foo/businesses <-- will go to Yelp API
From what I can tell, I can do this in a couple of ways..
Can somebody with a good handle on best practices comment on pros and cons of the two approaches (plus others if I'm missing any -- I'm aware I can probably do the whole thing in Javascript/node or Java but those don't sound like a good idea.
I am looking for specific architectural reasons, and maybe the implementation options for each.. For example, with option #1, I think I can either do a service callout, OR I can alter the request.targetUrl property (not sure about name)... So if option #1 has two derivatives, is one better than the other, etc?
Thanks in advance for the help
Solved! Go to Solution.
Hi @Kd Ford,
From the best practices point of view, you should always try to adhere to separation of concerns. If they serve the same purpose then keep them in one proxy and use route rules to route request pertaining to a target system based on proxy.pathsuffix and other conditions based on your requirement.
As you mentioned /foo/weather is dealing with only with weather APIs then keep it in a separate proxy with basepath /foo/weather similarly for others.
As you mentioned using conditional flows for a target system by overwriting "target.url", this will not be a good approach and will give you maintenance nightmare.
Hi @Kd Ford,
From the best practices point of view, you should always try to adhere to separation of concerns. If they serve the same purpose then keep them in one proxy and use route rules to route request pertaining to a target system based on proxy.pathsuffix and other conditions based on your requirement.
As you mentioned /foo/weather is dealing with only with weather APIs then keep it in a separate proxy with basepath /foo/weather similarly for others.
As you mentioned using conditional flows for a target system by overwriting "target.url", this will not be a good approach and will give you maintenance nightmare.
Thank you Mohammed for the answer/clarification.
Top dig a little deeper... I would configure route rules in my proxy endpoint and then add an additional target endpoint for every new path I need to serve (while considering associating like-routes within a single api proxy and different routes in other api proxies? such as the pseudo code below?
assuming I want this in one api proxy
Do I have it?
Hi @Kd Ford ,
Do you have different target systems from where you are fetching data for /theaters , /theaters/{id}/movies?
If they are all going to one target system then use conditional flows in this scenario.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |