我想在spring cloud gateway中为不同的api添加自定义路径。
我有两个api:
- 服务1:
http://localhost:2121
服务 1 的端点如下:http://localhost:2121/abc
- 服务2:
http://localhost:3434
服务 2 有类似的端点http://localhost:3434/abc
api网关:http://localhost:8090
问题:
我想将 service1 路径添加到 API Gateway,并且我想重定向到服务 1
示例 1:http://localhost:8090/service1/abc应该重定向到http://localhost:2121/abc
示例 2:http://localhost:8090/service1/anything应该重定向到http://localhost:2121/anything
服务 2 也一样。
我为 spring 云网关使用 yml 配置。
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: service1
uri: http://localhost:2121
- id: service2
uri: http://localhost:3434
提前致谢。