[英]Spring Cloud Gateway route builder has missing predicate option
I want to add a predicate to my spring gateway route below我想在下面的 spring 网关路由中添加一个谓词
public RouteLocator routeLocator(RouteLocatorBuilder builder,
CredentialsAuthRoutePredicateFactory ca) {
return builder.routes()
.route("superGraph - get data",r -> r
.path( "/alcoholic-alpaca/**")
.predicate(...)
However, the predicate option is underlined, and this error is showing up:但是,谓词选项带有下划线,并且出现了此错误:
'predicate' is not public in 'org.springframework.cloud.gateway.route.builder.BooleanSpec'. Cannot be accessed from outside package
How can i access predicate in this case?在这种情况下如何访问谓词?
path(String path)
method of PredicateSpec
is also a predicate (like a special case), so if you want multiple predicates you should call BooleanSpec
's and()
or or()
method (depends on your scenario) and then call another predicate method, like this: PredicateSpec
的path(String path)
方法也是一个谓词(就像一个特殊情况),所以如果你想要多个谓词,你应该调用BooleanSpec
的and()
或or()
方法(取决于你的场景)然后调用另一个谓词方法,像这样:
public RouteLocator routeLocator(RouteLocatorBuilder builder, CredentialsAuthRoutePredicateFactory ca) {
return builder.routes()
.route("superGraph - get data",
r -> r.path( "/alcoholic-alpaca/**")
.and() // or() ?
.predicate(alpacaPredicate)
.filters(f -> f.filter(alpacaFilter))
.uri(soberAlpacaUri))
.build();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.