如何在Spring WebFlux中创建重定向Rest Web服务?WebFlux中似乎还没有重定向功能!
我想要这样的东西:
@Bean
RouterFunction<ServerResponse> monoRouterFunction() {
return
route(GET("/redirect/{id}"),{
req -> req.Redirect( fetchAUrlFromDataBase() )
})
Run Code Online (Sandbox Code Playgroud) 在使用项目反应器库的 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)