我目前正在实现Spring,希望将我的路由指定为多个文件,如下所示:
最初,我们有一个配置,它有通往A&B rest端点的路由。
Spring Cloud Gateway fronts Rest Endpoint A and Rest Endpoint B
- Created YML 1 with routes to A and B (Refer below)
YML 1
----------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400几天后,我需要将路由添加到另一个Rest端点C。我不想接触原始配置(YML 1),而是希望为C创建一个新的YML,并期望路由C附加到原始路由A和B(类似于Apache )。
要有多个YML,请参考以下链接中的建议:Spring启动和多个外部配置文件
Spring Cloud Gateway fronts Rest Endpoint A, B and C
- Existing YML 1 with routes to A and B (Refer below)
- Created YML 2 with route to C (Refer below)YML 1
----------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400
YML 2
-----------------
spring:
cloud:
gateway:
routes:
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500Expectation
-----------------------
spring:
cloud:
gateway:
routes:
- id: RouteA
uri: https://httpbin.org/
predicates:
- Path=/status/200
- id: RouteB
uri: https://httpbin.org/
predicates:
- Path=/status/400
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500Actual Outcome
-------------------------
spring:
cloud:
gateway:
routes:
- id: RouteC
uri: https://httpbin.org/
predicates:
- Path=/status/500
Routes(A, B, C) do not get appended, instead it only picks up the latest configuration (YML 2 - Route C) in the property chain 如果其他人对如何实现这一点有什么好主意,请提出建议。欢迎所有的帮助和评论。
发布于 2020-07-30 21:33:33
我想出的最好的方法(实际上不是什么解决方案,而是一个折衷方案)是使用大型的ASCII头(带有一些像patorjk这样的在线工具)。它使导航更容易一目了然,特别是在使用崇高文本时。

这离理想还很远,但我觉得现在还可以。
https://stackoverflow.com/questions/60863665
复制相似问题