小编Neo*_*ith的帖子

如何在Spring Webflux中重定向请求?

如何在Spring WebFlux中创建重定向Rest Web服务?WebFlux中似乎还没有重定向功能!

我想要这样的东西:

 @Bean
RouterFunction<ServerResponse> monoRouterFunction() {
    return 
        route(GET("/redirect/{id}"),{
            req -> req.Redirect( fetchAUrlFromDataBase() )
        })
Run Code Online (Sandbox Code Playgroud)

spring url-redirection spring-boot spring-webflux

3
推荐指数
2
解决办法
2601
查看次数

如何避免 .flatMap(x-&gt;reactiveAction(x).thenReturn(x))

在使用项目反应器库的 Java 响应式编程期间,我偶然发现了一种模式,我想知道是否有开箱即用的支持?

所以我想要下面的代码:

Mono.just("hello")
    .flatMap(hello -> reactiveAction(hello).thenReturn(hello))
    ..
    .;
Run Code Online (Sandbox Code Playgroud)

变成类似的东西:

Mono.just("hello")
    .coolOperation(this::reactiveAction)
    ..
    .;   
Run Code Online (Sandbox Code Playgroud)

我不能使用 doOnNext 因为我想在 reactAction 中做的不是副作用。和反应动作是:

Mono<Integer> reactiveAction(String text){
  return ....
}
Run Code Online (Sandbox Code Playgroud)

java mono publisher reactive-programming project-reactor

1
推荐指数
1
解决办法
288
查看次数