问题描述
我有一个>>> ls -ld firefox
drwxr-xr-x 8 root root 4096 Oct 26 10:22 firefox
配置,如下所示:
spring-cloud-gateway
此路由有望接受两种类型的请求:
@Bean
public RouteLocator gatewayRoutes(RouteLocatorBuilder builder) {
return builder.routes()
.route(r -> r.path("/api/bank/account/user/**") //intercept calls to
.uri("http://mrq-bank-account.cloud.host/")
.id("bankModule"))
.build();
}
和
/api/bank/account/user/savingsAccount
第一个请求带有一个/api/bank/account/user/studentAccount
对象,第二个请求带有一个SavingsAccount
对象。这两个对象都有一个StudentAccount
属性,我需要提取该属性。通过添加到userRef:String
上,可以通过某种方式做到这一点吗?
基本上,我正在尝试找出如何从像上述那样的spring-cloud-gateway配置中的传入请求所携带的对象中提取属性。
这是库方法,我认为可以用来实现这一目标:
cloud-gateway-configuration
但是我想使用它来提取读取对象的属性之一的值,然后使用该值来调用将返回主机名的服务-最终必须从{{1 }}方法
package org.springframework.cloud.gateway.route.builder;
/**
* This predicate is BETA and may be subject to change in a future release. A
* predicate that checks the contents of the request body
* @param inClass the class to parse the body to
* @param predicate a predicate to check the contents of the body
* @param <T> the type the body is parsed to
* @return a {@link BooleanSpec} to be used to add logical operators
*/
public <T> BooleanSpec readBody(Class<T> inClass,Predicate<T> predicate) {
return asyncPredicate(
getBean(ReadBodyRoutePredicateFactory.class).applyAsync(c -> c.setPredicate(inClass,predicate)));
}
中的此方法也很有用
uri()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)