I have two micro service, user micro service and order micro service.
User micro service return's the user details and order micro service return the order details for the user.
http://localhost:8080/microservice1/getuser
{"id":"100","name":"test"}
http://localhost:8081/microservice2/getorders
{"userid":"100","orders":{"orderid":"5001","productname":"mobilephone"}}
I am using Spring cloud Zuul as API Gateway which is routing request to each micro service.
http://localhost:9090/api/microservice1/getuser
http://localhost:9090/api/microservice2/getorders
Now from UI, i need to call two endpoints
Is their any way to merge the response of both the micro service like {"id":"100","name":"test","orders":{"orderid":"5001","productname":"mobilephone"}}
So that client only need to call one endpoint http://localhost:9090/api/getdetail
how we can achieve this at API Gateway level ?
Zuul should not be use to aggregate response , you can create orchestration microservice service and internally using restTemplate get all response and aggregate as per need.
Keep Zuul as stateless, gateway should not have any logic or stateful.