The functional programming model

The functional programming model uses the API that has functional interfaces such as RouterFunction and HandlerFunction. It uses Java 8 Lambda style programming with routing and request handling instead of the Spring MVC annotations. They are simple, but powerful, building blocks for creating web applications.

The following is an example of functional request handling:

    package com.packt.patterninspring.chapter11.web.reactive.function; 
 
    import static org.springframework.http.MediaType.APPLICATION_JSON; 
    import static org.springframework.web.reactive.      function.BodyInserters.fromObject; 
 
    import org.springframework.web.reactive.      function.server.ServerRequest; 
    import org.springframework.web.reactive. function.server.ServerResponse; ...

Get Spring 5 Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.