Spring Web Flux Procedure Tutorial
This tutorial demonstrates configuring a Spring Web Flux Controller as a procedure.
Adding a Spring Web Flux Controller as a procedure, allows re-use of existing code. Ideally, over time, the Spring Web Flux Controllers are simplified to methods taking advantage of OfficeFloor's IoCC. However, Spring Web Flux Controllers are supported as procedures to avoid significant rewrites of application code. This enables taking advantage of OfficeFloor's features with existing Spring code.
Configuring Spring Web Flux Controller
Please see the Spring Web Flux Controller Tutorial regarding configuring Spring Web Flux Controllers into WoOF. The tutorial needs to be followed to also enable Spring Web Flux Controllers to be configured as procedures.
Configuring as a Procedure
Spring Web Flux Controller methods are configured as procedures via REST endpoint YAML files. The following configures the GET rest endpoint:
get:
resource: net.officefloor.tutorial.springwebfluxhttpserver.SpringRestController
procedure: SpringWebFluxController
method: get
The path parameter endpoint:
path:
resource: net.officefloor.tutorial.springwebfluxhttpserver.SpringRestController
procedure: SpringWebFluxController
method: path
The PUT endpoint:
post:
resource: net.officefloor.tutorial.springwebfluxhttpserver.SpringRestController
procedure: SpringWebFluxController
method: post
Note that the WoOF configured paths can be different to the Spring Web Flux Controller request mappings. The only constraint on this is that the path parameters must match.
Testing
The following tests demonstrates the procedures.
@RegisterExtension
public static final MockWoofServerExtension server = new MockWoofServerExtension();
@Test
public void get() {
MockWoofResponse response = server.send(MockWoofServer.mockRequest("/officefloor/rest"));
response.assertJson(200, new ResponseModel("GET Spring Dependency"));
}
@Test
public void pathParam() {
MockWoofResponse response = server.send(MockWoofServer.mockRequest("/officefloor/changed/parameter"));
response.assertJson(200, new ResponseModel("parameter"));
}
@Test
public void put() {
MockWoofResponse response = server
.send(MockWoofServer.mockJsonRequest(HttpMethod.PUT, "/officefloor/update", new RequestModel("INPUT")));
response.assertJson(200, new ResponseModel[] { new ResponseModel("INPUT"), new ResponseModel("ANOTHER") });
}
Next
The next tutorial covers migrating Spring Web Flux Controllers for simpler code and avoid the dependency on Spring.

