TDDing http4k
This post is a guide to how we build http4k applications test first to provide excellent test coverage driven by decoupled tests.
Application Design
For this example, we will use an example of a Maths app with the following requirements:
- The app must add 2 numbers together via an HTTP call
- The app must multiply 2 numbers together via an HTTP call
- Answers generated by the service will be logged (via HTTP POST) to another server - the Recorder.
Apps can generally be split into 3 tiers:
- Endpoint:
HttpHandlersare constructed individually, by providing a builder function which takes the business-level dependencies. - Application: Builder function which takes the transport-level dependencies, and converts them into business-level dependencies. All routes are constructed and collected in this tier.
- Server: Builder function which takes the configuration for environmental concerns such as ports and downstream urls.
The tutorial is split into 4 sections:
- Part 1: Building a walking skeleton
- Part 2: Adding an endpoint
- Part 3: Adding another endpoint
- Part 4: Adding an external dependency
Getting Started
From your first http4k app through to serverless deployment on AWS Lambda with both standard JVM and GraalVM native runtimes.
Serverless http4k with AWS Lambda
A step-by-step guide to deploying an HTTP app to AWS Lambda
Going native with Graal on AWS Lambda
A step-by-step guide to compiling http4k apps with GraalVM for AWS Lambda
TDDing http4k
A multi-part walkthrough of building an http4k application test-first, covering endpoint design, routing, and external dependencies.
TDDing http4k Part 1: Building a walking skeleton
A step-by-step guide to TDDing a simple http4k application
TDDing http4k Part 2: Adding an endpoint
A step-by-step guide to TDDing a simple http4k application
TDDing http4k Part 3: Adding another endpoint
A step-by-step guide to TDDing a simple http4k application
TDDing http4k Part 4: Adding an external dependency
A step-by-step guide to TDDing a simple http4k application
Building with MCP
Build MCP servers and interactive MCP Apps with http4k's Kotlin-first Model Context Protocol SDK.
Create an MCP Server in 2 Lines of Code
Build a working MCP server with http4k in just a few lines of Kotlin
Add MCP Capabilities
Add typed tool arguments, resources, prompts, and in-memory testing to an http4k MCP server
Building an MCP App with http4k
A step-by-step guide to building an interactive MCP App with http4k
