spring-five-functional-reactive
spring-five-functional-reactive copied to clipboard
= Spring 5 - Functional, reactive web example
This repository contains the sample code for Spring WebFlux's functional web API and consists of the following building blocks:
== A sample for Spring WebFlux
- An
Eventdomain type and a corresponding repository exposing a tailable query method. - An
ApplicationRunnerthat creates a capped collection for events and inserts a new one every two seconds. - A Spring WebFlux controller to produce both a Server-Sent Events and JSON stream.
== A sample for Spring WebFlux.fn
- A
Userdomain type and a reactive repository mapped using Spring Data MongoDB. - A
FunctionalWebControllerto contain handler functions. - An
@Bean-Definition for aRouterFunctionthat uses the functional API to configure the mappings of requests to theFunctionalWebController.
== How to run the sample
$ git clone https://github.com/olivergierke/spring-five-functional-reactive
$ cd spring-five-functional-reactive
$ ./mvnw spring-boot:run
# To see the events inserted on the server streaming to the client
$ curl -H "Accept: text/event-stream" http://localhost:8080/events
# To trigger the functional controller
$ curl http://localhost:8080/users