Best practices for Calling Multiple backends

Hi All,

I have an API proxy with multiple paths exposed. When request comes then based on backend name in the payload it has to be routed to different backend APIs.

All the backend APIs need different message payload and authentication details.

What is the best practice for implementing this use case?

1) Create multiple route rules and multiple Target end points with condition based on request path and backend name from payload. Then do the transformation to backend format in the pre flow of target endpoint and call the backend API.

2) Have only one default route rule with multiple conditional flows with condition based on request path and backend name from payload.

1) Is there any other better way of doing this?

2) Where the backend request should be formed, in proxy endpoint or target end point?

2) In which flow backend response should be transformed to Client response, in target response pre/post flow or proxy end point pre/post flow?

0 1 1,239
1 REPLY 1

It can be done in multiple ways depending on your resources.

Option 1 -

As a best practise it is advisable to create/maintain a separate proxy for each/different backend/targets.

If there are multiple APIs that share a common starting basepath, but differ in the suffix, use conditional flows in a ProxyEndpoint.

Option 2 -

If you have a limit on the number of proxies in an org, then yes, use multiple route rules with appropriate Conditions and route to different TargetEndpoints.

I prefer building the backend request on the Proxy Endpoint and transforming the backend response on the TargetEndpoint response.

Reading your requirement, you may also require multiple ProxyEndpoints in the same proxy to handle different authentication details and this will make your proxy messy. This approach will make it hard for developers to understand and maintain the API proxy.