【发布时间】:2019-01-25 07:55:13
【问题描述】:
Spring Cloud Greenwich 将 spring-cloud-netflix-zuul 置于维护模式,因此我正在尝试从 Zuul 迁移到 Spring Cloud Gateway。
使用 Zuul,我有一条类似的路线
zuul:
routes:
masterplan_match:
path: /**/masterplans/**
serviceId: api-masterplan
我在那里所做的基本上是忽略接收路径中masterplan 之前或之后的所有内容,并重定向到api-masterplan。例如/some/path/to/masterplans和/masterplans都去同一个api(原因是masterplans是一个更大实体的子资源,它负责创建新的masterplans,但是那么masterplans可以被视为用于GETting 详细信息、更新、删除等目的的完整资源)。
我可以将此配置映射到 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/**
我是否遗漏了什么,这两条路径能否浓缩为一?
【问题讨论】:
-
这解决了你的问题吗?
- Path=/some/path/to/masterplans/**, /masterplans/** -
@Som 很抱歉回复晚了,但它没有帮助。与此同时,我以某种方式解决了这个问题,但也换了公司,老实说,我不记得如何了。另外,Spring Cloud Gateway 上可能有很多开发,但遗憾的是没有机会再次使用该项目
-
没问题的哥们。反正我解决了。感谢您的回复。干杯!
-
现在确认这个工作......在文档中的任何地方都找不到它......