Fork me on GitHub

Static Content Tutorial

This tutorial demonstrates servicing static content (files) with WoOF.

Tutorial Source

/PUBLIC

To have static files served by WoOF, create a PUBLIC folder on the class path. Any files within this directory will be served as static files by WoOF.

As anything on the class path /PUBLIC/** is served as static files, this gives a lot of flexibility in making the static files of the single page application available:

  • by copying the files into the built jar
  • by creating a separate jar containing the static files and adding to the runtime class path
  • other mechanisms, so the static files can be found by class path lookup

Testing

The following shows obtaining the index.html static file:

	@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>");
	}

Next

The next tutorial covers logging.