Search⌘ K
AI Features

Building HTTP Server for Wordz Application

Explore how to test-drive the implementation of an HTTP server for the Wordz application using the Molecule library. Learn to add endpoints and routes, handle HTTP methods, and connect the web layer to the domain logic. This lesson guides you through small, incremental development steps to build a functional and testable web server.

The failing test allows us to test-drive code that implements an HTTP server. We’ll use the Molecule library to provide HTTP services to us.

Adding an endpoint

  • We add an endpoint class, which we’ll call the WordzEndpoint class:

Java
@Test
void startGame() throws IOException,
InterruptedException {
var endpoint
= new WordzEndpoint("localhost", 8080);

The two parameters passed into the WordzEndpoint constructor define the host and port that the web ...