开端
其实建议查手册,但是我懒,所以就写出一个配置文件范本来供自己参考.
范本
spring:
gateway:
routes:
- id: product_route
uri: lb://demomarket-product
predicates:
- Path=/api/product/**
filters:
- RewritePath=/api/(?<segment>.*),/$\{segment}
- id: third_party_route
uri: lb://demomarket-third-party
predicates:
- Path=/api/thirdparty/**
filters:
- RewritePath=/api/thirdparty/(?<segment>.*),/$\{segment}
- id: admin_route
uri: lb://renren-fast
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*),/renren-fast/$\{segment}
application:
name: demomarket-gateway
注意
一定注意routes的predicates的顺序,从叶子路由的到根路由,先细后粗,先礼后兵,先上车后刷卡.不然路由会被遮掩.