Building on top of the reactive features, Spring 5 also provides a functional web framework.
A functional web framework provides features to define endpoints using functional programming style. A simple hello world example is shown here:
RouterFunction<String> route = route(GET("/hello-world"), request -> Response.ok().body(fromObject("Hello World")));
A functional web framework can also be used to define more complex routes, as shown in the following example:
RouterFunction<?> route = route(GET("/todos/{id}"), request -> { Mono<Todo> todo = Mono.justOrEmpty(request.pathVariable("id")) .map(Integer::valueOf) .then(repository::getTodo); return Response.ok().body(fromPublisher(todo, Todo.class)); }) .and(route(GET("/todos"), ...