I am new to Spring. I was trying to make a sample application for spring webflux in functional way. Why can't our handler function pass Flux. is there any way to make router function accept it as it is said that router function accept a subtype of serverResponse.
Show Handler code
public Mono<ServerResponse> getShowList(ServerRequest request){
Flux<Show> showList = showRepository.findAll();
Flux<ShowVo> showVoList= showList.map(s -> {
return new ShowVo(s.getId(), s.getTitle());
});
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(showVoList, ShowVo.class); }
Here i am passing the Mono <ServerResponse> but I want to it as Flux <ServerResponse> to the Router function
Router function code
@Bean
public RouterFunction<ServerResponse> routeShow(ShowHandler showHandler){
return RouterFunctions.route(RequestPredicates.GET("/shows").and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), showHandler::getShowList)
}
}
So is there any way to do it, I have gone through different articles. All I can find is Mono but if I use annotation based webflux I can pass flux.