This tutorial demonstrates serving static assets — HTML, CSS, JavaScript, images — for a single-page application alongside OfficeFloor REST endpoints.
The two halves of a modern web application sit in separate locations on the classpath:
| Location | Purpose |
|---|---|
officefloor/rest/ |
REST endpoint YAML files (the API) |
PUBLIC/ |
Static assets served directly (the SPA) |
No routing configuration is needed. OfficeFloor serves any path under PUBLIC/ as a static file, and routes everything else through the REST endpoint declarations.
Place static files anywhere on the classpath under a directory named PUBLIC. Any file found at PUBLIC/{path} is served at GET /{path}. The root path / maps to PUBLIC/index.html.
This gives flexibility in how the SPA build output is packaged:
src/main/resources/PUBLIC/ and they are bundled into the application jar. @RegisterExtension
public MockWoofServerExtension server = new MockWoofServerExtension();
@Test
public void indexPage() throws Exception {
MockHttpResponse response = this.server.send(MockHttpServer.mockRequest("/"));
response.assertResponse(200, "<html><body>Hello World</body></html>");
}
The Reactor tutorial shows how to integrate Project Reactor publishers and subscribers as OfficeFloor procedures.