【发布时间】:2019-09-12 22:42:20
【问题描述】:
我有两个微服务,用户微服务和订单微服务。
用户微服务返回用户详情,订单微服务返回用户订单详情。
http://localhost:8080/microservice1/getuser
{"id":"100","name":"test"}
http://localhost:8081/microservice2/getorders
{"userid":"100","orders":{"orderid":"5001","productname":"mobilephone"}}
我使用 Spring cloud Zuul 作为 API 网关,将请求路由到每个微服务。
http://localhost:9090/api/microservice1/getuser
http://localhost:9090/api/microservice2/getorders
现在从 UI,我需要调用两个端点
他们有什么方法可以合并这两个微服务的响应吗? {"id":"100","name":"test","orders":{"orderid":"5001","productname":"mobilephone"}}
这样客户端只需要调用一个端点http://localhost:9090/api/getdetail
我们如何在 API 网关级别实现这一点?
【问题讨论】:
标签: java spring spring-boot microservices api-gateway