Tha*_*ish 4 spring-cloud-gateway
Spring Cloud Greenwich 进入spring-cloud-netflix-zuul维护模式,因此我尝试从 Zuul 迁移到 Spring Cloud Gateway。
使用 Zuul 我有一条类似的路线
zuul:
routes:
masterplan_match:
path: /**/masterplans/**
serviceId: api-masterplan
Run Code Online (Sandbox Code Playgroud)
我在那里所做的基本上是忽略masterplan接收路径中之前或之后的所有内容并重定向到api-masterplan. 例如, 和/some/path/to/masterplans都/masterplans使用相同的 api(原因是masterplans它们是一个更大实体的子资源,负责创建新的masterplans,但随后masterplans可以被视为完整的资源,用于设置GET详细信息、更新、删除等目的)。
我可以将此配置映射到 Spring Cloud Gateway 吗?查看predicates,可行的似乎是path predicate,但看起来所有匹配器都适用于单个路径元素(除了WildcardTheRestPathElement,但它只能用作最后一个元素 - 我认为),即:我需要写就像是
spring
cloud:
gateway:
routes:
- id: masterplan_match
uri: lb://api-masterplan # Coming from discovery client
predicates:
- Path=/some/path/to/masterplans/**, /masterplans/**
Run Code Online (Sandbox Code Playgroud)
我是否遗漏了一些东西,两条路径可以浓缩为一条吗?
小智 12
Spring Cloud Gateway 自版本以来支持多种模式2.1.0
spring
cloud:
gateway:
routes:
- id: masterplan_match
uri: lb://api-masterplan # Coming from discovery client
predicates:
- Path=/some/path/to/masterplans/**, /masterplans/**
Run Code Online (Sandbox Code Playgroud)
也可以看看:
| 归档时间: |
|
| 查看次数: |
16703 次 |
| 最近记录: |