当前位置:网站首页>使用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();
}
希望
边栏推荐
- Knowledge of two-dimensional array
- Lua get started quickly
- Kibana6.2.4 version update x-pack certification
- How to make digital retail undertake the development task of the era of traffic and retention may be the key
- 面试题 01.07. 旋转矩阵
- Spreadsheet export excel table
- Lecture 16 of project practice: using the open close principle to realize the commodity price rule engine
- Gazebo control example
- 2022/07/27 学习笔记 (day17) 代码块和内部类
- Software testing interview question: where do your performance testing requirements come from?
猜你喜欢

现货白银如何计算盈亏

JUC concurrent programming learning

Cesium add dynamic pop-up

Learn how Baidu PaddlePaddle easydl realizes automatic animal recognition in aquarium

Codeforces暑期训练周报(7.21~7.27)

8000字讲透OBSA原理与应用实践

Develop plug-ins for the recording function of flutter

Lua get started quickly

Count the number of given strings in a string

Icml2022 | online decision transformer
随机推荐
"Wei Lai Cup" 2022 Niuke summer multi school training camp 3 supplementary problem solution (a, C, J)
In April, global smartphone shipments fell 41% year-on-year, and Huawei surpassed Samsung to become the world's first for the first time
软件测试面试题:你们的性能测试需求哪里来?
URDF 集成 Gazebo
Three instance
Introduction and configuration of vsftpd
Jingfang Technology: ASML, a lithography machine manufacturer, is one of the main customers of Anterion company, which participated in the merger and acquisition of the company
Cross domain requests in nodejs
How to make digital retail undertake the development task of the era of traffic and retention may be the key
Standing at the crossroads of digital retail transformation, we need to look at it from a new perspective
String
URDF integrated gazebo
String
3年经验想拿20K,居然面了半个月都没拿到?
软件测试面试题:如何发现数据库的相关问题?
Sort out SQL performance optimization and collect classics!
Rviz uses arbotix to control robot motion
Briefly understand namenode and datanode
彻底搞懂kubernetes调度框架与插件
Harmonyos 3 was officially released: Hongmeng mobile phones are smooth and safe, and Hongmeng terminals are often used