[英]Spring Cloud Gateway Route URL pattern configuration
我已經使用 Eureka 發現服務實現了 Spring 雲網關,一切正常,但我看到了一些我在編寫 URL 時不知道如何處理的東西,如果我沒有在末尾添加 / URL 網關直接使用其實際的 URL(在 Eureka 中注冊)重定向到應用程序。
例如:
有沒有可以避免第一種情況的配置?
我的配置如下:
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
- id: bar-service
uri: lb://BAR-SERVICE/
predicates:
- Path=/bar/**
- id: other-service
uri: lb://OTHER-SERVICE/
predicates:
- Path=/OTHER/**
附加信息:
任何建議將被認真考慮! 干杯!
您應該在網關配置中使用 RewritePath。 以下是示例,希望對您有所幫助。
spring:
application:
name: gateway-service
cloud:
gateway:
routes:
- id: bar-service
uri: lb://BAR-SERVICE/
predicates:
- Path=/bar/**
filters:
- RewritePath=/bar(?<segment>.*), /$\{segment}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.