spring cloud gateway url重写
生活随笔
收集整理的這篇文章主要介紹了
spring cloud gateway url重写
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
將/a/b/c指向到/f/c的控制示例:
spring:cloud:gateway:routes:# =====================================- id: rewritepath_routeuri: http://example.orgpredicates:- Path=/a/b/**filters:- RewritePath=/a/b/(?<segment>.*), /f/$\{segment}參見官方文檔
RewritePath GatewayFilter Factory
The RewritePath GatewayFilter Factory takes a path?regexp?parameter and a?replacement?parameter. This uses Java regular expressions for a flexible way to rewrite the request path.
application.yml.?
spring:cloud:gateway:routes:# =====================================- id: rewritepath_routeuri: http://example.orgpredicates:- Path=/foo/**filters:- RewritePath=/foo/(?<segment>.*), /$\{segment}For a request path of?/foo/bar, this will set the path to?/bar?before making the downstream request. Notice the?$\?which is replaced with?$?because of the YAML spec.
總結
以上是生活随笔為你收集整理的spring cloud gateway url重写的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java实现经典坦克大战及源代码下载
- 下一篇: 浅谈NFC、RFID、红外、蓝牙的区别