february 2018 / @daviddenton¶
This post is a guide to how we build http4k applications test first to provide excellent test coverage driven by decoupled tests.
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:
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: