【发布时间】:2019-06-11 10:06:48
【问题描述】:
我使用 spring zuul 来管理 API_Gateway。但是我的基本问题是无法将请求转发到特定路径。我的服务中存在多个不可更改的地址,我将从特定地址转发。我更喜欢不使用“Zuulfilter”,但使用它并没有用。
用户请求:(没关系)
浏览器请求:gateway.com/api1/user → gateway → apihost.com/api1/user
大摇大摆的请求:(失败了)
浏览器请求:gateway.com/api1/swagger → gateway → apihost.com/swagger-ui.html
我使用 service_discovery (eureka) 并且我的 application.yml 文件配置是:
Zuul:
routes:
swagger:
path: /api1/swagger
service_id: api1
url: forward:/swagger-ui.html#/
users:
path: /api1/user/**
service_id: api1
stripPrefix: false
但我在调试模式下看到:
2019-01-17 11:28:46.437 DEBUG 77407 --- [nio-8181-exec-4] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Did not find handler method for [/swagger-ui.html#/api1/swagger]
2019-01-17 11:28:46.437 DEBUG 77407 --- [nio-8181-exec-4] a.e.w.s.ControllerEndpointHandlerMapping : Looking up handler method for path /swagger-ui.html#/api1/swagger
2019-01-17 11:28:46.437 DEBUG 77407 --- [nio-8181-exec-4] a.e.w.s.ControllerEndpointHandlerMapping : Did not find handler method for [/swagger-ui.html#/api1/swagger]
我还添加了一个路由过滤器(Zuulfilter),用于直接从服务调用地址,但响应不同。无论如何使用 Zuul 配置来完成转发(关于我使用服务发现)如果不存在开发 servlet 过滤器的示例代码吗?
【问题讨论】:
标签: java spring-boot netflix-zuul api-gateway