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.
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.
Select the Spring Web Flux Controller as a class when adding a procedure.
Note: the Controller must be on the application's Spring scan path.
The tutorial configuration is as follows:
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.
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") }); }
The next tutorial covers migrating Spring Web Flux Controllers for simpler code and avoid the dependency on Spring.