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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.