当前位置:网站首页>使用Gateway的流式api修改请求路径
使用Gateway的流式api修改请求路径
2022-07-27 23:34:00 【Java精灵儿】
在官网看到这样的写法
spring:
cloud:
gateway:
routes:
- id: nameRoot
uri: https://nameservice
predicates:
- Path=/name/**
filters:
- StripPrefix=2
当网关转发请求路径为 /name/blue/red时,实际上是向nameservice转发的nameservice/red请求,官网中并没有给出流式api的栗子
可以使用下面的代码来实现
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("oauth",
f-> f.path("/oauth/**")
.filters(gatewayFilterSpec -> gatewayFilterSpec.rewritePath("/oauth",""))
.uri("lb://oauth")
).build();
}
但是还是有问题,如果将官网的改成用流式api来写的话,你怎么知道name的后面一定是blue呢就像下面这样
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route("nameRoot",
f-> f.path("/name/**")
//问题在这里
.filters(gatewayFilterSpec -> gatewayFilterSpec.rewritePath("/name/blue",""))
.uri("lb://nameservice")
).build();
}
希望
边栏推荐
- Three instance
- 内容bypass分享
- How to calculate the profit and loss of spot Silver
- docker 本地搭建mysql主从
- Meguiar sued liandian for secret theft and sentenced: liandian was fined NT $100million and three employees were sentenced!
- 面试题 01.06. 字符串压缩
- 软件测试面试题:如何发现数据库的相关问题?
- Interpretation of new features | the restriction of MySQL 8.0 on gtid is lifted
- Leetcode 2341. How many pairs can an array form
- Shaanxi Yuanjie semiconductor, a laser chip manufacturer, was invested by 8 investment institutions including GF Securities and CITIC Securities
猜你喜欢

迅为i.MX6ULL开发板Qt系统移植-交叉编译Qt代码

Icml2022 | online decision transformer

PHP利用某些函数bypass waf探讨

Unity Shader入门精要学习——基础纹理

【C语言】文件操作

Leetcode 2341. How many pairs can an array form

Codeforces summer training weekly (7.21~7.27)

I want to get 20K after 3 years of experience, but I haven't got it for half a month?

Sort out SQL performance optimization and collect classics!

Knowledge of two-dimensional array
随机推荐
自定义事件
梳理 SQL 性能优化,收藏经典!
Cesium add annular diffusion ripple
Three basic teaching
C language main function transfer parameters
Neuron 2.1.0 release: it supports sparkplug B specification and more complete industrial protocol support
Byte monthly salary 28K, share a wave of my automation testing experience
I want to get 20K after 3 years of experience, but I haven't got it for half a month?
URDF 集成 Gazebo
S-RPN: Sampling-balanced region proposal network for small crop pest detection
Software test interview question: how to find problems related to the database?
LeetCode 2347. 最好的扑克手牌
BYD semiconductor completed the a+ round financing of 800million yuan: 30 well-known investment institutions entered the market, with a valuation of 10.2 billion yuan!
Count the number of given strings in a string
Oracle Rac 集群文件目录迁移
Cross domain requests in nodejs
Codeforces summer training weekly (7.14~7.20)
What is the opening time of London Silver
Huami technology "Huangshan No.2" release: AI performance is improved by 7 times, and power consumption is reduced by 50%!
How to solve the pain points of 12000 small and medium-sized customers' component procurement? Say goodbye to overtime!