server:
port: 80
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
- id: data-service1 #任意,表示一个路由规则
uri: lb://data-producer #在服务注册中心找服务名为 data-producer的服务,服务集群自动负载均衡
predicates:
- Path=/data-service1/* #设置路由断言,当url为http://localhost:80//data-service1/任意一个值 时交给data-producer服务器处理
filters:
- StripPrefix=1
- id: data-service2 # 。。。。。
uri: http://localhost:8080
predicates:
- Path=/data-service2/*
#前缀, 在当前路径匹配中表示去掉第一个前缀 /data-service2
filters:
- StripPrefix=1
# 给每次请求都添加一个前缀 /user比如请求:http://localhost:18084/2-->http://localhost:18084/user/2
filters:
- PrefixPath=/user
gateway的配置文件
最新推荐文章于 2023-12-01 21:26:43 发布