Fork me on GitHub

Spring Web Flux Tutorial

This tutorial demonstrates configuring Spring Web Flux Controllers within WoOF. This enables using an existing Spring Application out of the box within WoOF.

Tutorial Source

Spring Web Flux Controller

The Spring Web Flux Controller to be integrated is as follows:

public class SpringRestController {

	private SpringDependency dependency;

	public Mono<ResponseModel> get() {
		return Mono.just(new ResponseModel("GET " + this.dependency.getMessage()));

	public Mono<ResponseModel> path(@PathVariable String param) {
		return Mono.just(new ResponseModel(param));

	public Flux<ResponseModel> post(@RequestBody RequestModel request) {
		return Flux.just(new ResponseModel(request.getInput()), new ResponseModel("ANOTHER"));


With the request and response models:

public class RequestModel {

	private String input;
public class ResponseModel {

	private String message;

Configuring Spring Web Flux Controller

To configure using Spring Web Flux Controller instances within WoOF, add the following dependency:


Spring will also need to be configured in application.objects:

	<supplier source="SPRING">
		<property name="configuration.class" value="net.officefloor.tutorial.springwebfluxhttpserver.Application" />


This will have all the Spring Web Flux Controllers available at their request mapped paths.


The following tests demonstrate the Spring Web Flux Controllers servicing requests.

	public static final MockWoofServerExtension server = new MockWoofServerExtension();

	public void get() {
		MockWoofResponse response = server.send(MockWoofServer.mockRequest("/rest"));
		response.assertJson(200, new ResponseModel("GET Spring Dependency"));

	public void pathParam() {
		MockWoofResponse response = server.send(MockWoofServer.mockRequest("/rest/path/parameter"));
		response.assertJson(200, new ResponseModel("parameter"));

	public void post() {
		MockWoofResponse response = server
				.send(MockWoofServer.mockJsonRequest(HttpMethod.POST, "/rest/update", new RequestModel("INPUT")));
		response.assertJson(200, new ResponseModel[] { new ResponseModel("INPUT"), new ResponseModel("ANOTHER") });


The next tutorial covers configuring a Spring Web Flux Controller as a procedure.