Java 使用弹簧反应器的正确方法是什么;s changeRequestUri()?

Java 使用弹簧反应器的正确方法是什么;s changeRequestUri()?,java,spring,spring-boot,project-reactor,spring-reactor,Java,Spring,Spring Boot,Project Reactor,Spring Reactor,有人能提供一个例子和解释如何使用这种方法吗? 我是ProjectReactor的新手,我很难理解如何使用它,而且似乎没有足够的教程。 我想要的是调用一个服务,该服务将以字符串格式返回主机名,然后将其作为uri发送给用户 这是方法的包和方法: org.springframework.cloud.gateway.route.builder /** * A filter which change the URI the request will be routed to by the Gate

有人能提供一个例子和解释如何使用这种方法吗? 我是ProjectReactor的新手,我很难理解如何使用它,而且似乎没有足够的教程。 我想要的是调用一个服务,该服务将以字符串格式返回主机名,然后将其作为uri发送给用户

这是方法的包和方法:

org.springframework.cloud.gateway.route.builder



/**
 * A filter which change the URI the request will be routed to by the Gateway.
 * @param determineRequestUri a {@link Function} which takes a
 * {@link ServerWebExchange} and returns a URI to route the request to
 * @return a {@link GatewayFilterSpec} that can be used to apply additional filters
 */
public GatewayFilterSpec changeRequestUri(Function<ServerWebExchange, Optional<URI>> determineRequestUri) {
    return filter(new AbstractChangeRequestUriGatewayFilterFactory<Object>(Object.class) {
        @Override
        protected Optional<URI> determineRequestUri(ServerWebExchange exchange, Object config) {
            return determineRequestUri.apply(exchange);
        }
    }.apply(c -> {
    }));
}
org.springframework.cloud.gateway.route.builder
/**
*更改请求将由网关路由到的URI的筛选器。
*@param determineRequestUri是一个{@link Function},它接受
*{@link ServerWebExchange}并返回将请求路由到的URI
*@返回一个{@link GatewayFilterSpec},可用于应用其他筛选器
*/
公共网关筛选器spec changeRequestUri(函数determineRequestUri){
返回筛选器(新的AbstractChangeRequestUriGatewayFilterFactory(Object.class){
@凌驾
受保护的可选determineRequestUri(ServerWebExchange,对象配置){
退货决定申请(交换);
}
}.应用(c->{
}));
}