Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Small webflux application
public class AppRouter {
// works for a single bean
public RouterFunction<ServerResponse> routes(ResouceHandler resourceHandler) {
return RouterFunctions.route(GET("/resource/{id}").and(accept(APPLICATION_JSON)), resourceHandler::get)
.andRoute(GET("/resource/filter/{filterQuery}").and(accept(APPLICATION_JSON)), resourceHandler::getFiltered);
public class BookHandler {
private final AppService appService;
public BookHandler(AppService appService) {
this.appService = appService;
public Mono<ServerResponse> get(ServerRequest request) {
String id = request.pathVariable("id");
return ok()
.body(appService.getById(id), AppModel.class);
public interface AppRepository extends ReactiveCrudRepository<AppModel, String> {
Mono<AppModel> findById(Mono<String> id);
@Query("{ 'filter': ?0 }")
Flux<AppModel> findByFilter(String filter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment