// FAQ

The questions we get asked most.

Straight answers about the toolkit, its API and the ecosystem. Can't find yours? The Kotlin Slack and our inbox are both open.

General

Is http4k a library or a framework?
Neither! Although it has many of the features of a framework, the http4k ecosystem is a generalised Toolkit which enables the creation of HTTP-based applications. It is incredibly unopinionated and has been designed to not enforce design decisions on the API user. We use http4k for applications both large and small, using no DI framework.
What kind of systems run on http4k?

Mission-critical ones. http4k powers digital banks, financial risk systems and high-traffic platforms in production, with adoption across every industry sector - and has done for years. The biggest known deployment serves the global site traffic (rank ~700 globally) for a large academic publisher. http4k libraries are downloaded millions of times a month from Maven Central, and http4k was included in the Thoughtworks Tech Radar alongside other proven technologies used on Thoughtworks-delivered projects.

If you’re running http4k in production and would like to be listed on the site as an adopter, please get in touch.

Does http4k support an Async model? I need webscale!
http4k embraces project Loom’s Virtual Threads on the JVM, giving you the benefits of an async model out of the box - without complicating the API with the use of suspend etc. That’s deliberate: Loom makes direct coroutine support unnecessary. As for scaling, see the above answer relating to production usage, or checkout the benchmark results to see how http4k compares to other JVM-based sync and async web libraries.

API

I'm attempting to build HTTP messages using the API, but changes don't affect the object (e.g. calling `request.body("hello")`)?
http4k HTTP message objects are immutable, so you need to chain or reassign the value from the method call to get the updated version.
Where are all the useful Filters defined?

Filters are all in the import org.http4k.filter package and are located as methods on a singleton object relevant to their use:

  • org.http4k.filter.CachingFilters.Request & org.http4k.filter.CachingFilters.Response
  • org.http4k.filter.ClientFilters
  • org.http4k.filter.DebuggingFilters
  • org.http4k.filter.RequestFilters
  • org.http4k.filter.ResponseFilters
  • org.http4k.filter.ServerFilters
  • org.http4k.filter.TrafficFilters

Lenses & Auto-Marshalling

I am having a problem with the usage of Moshi, Jackson or GSON for auto marshalling
Please see the custom FAQ for JSON handling questions.
My application uses Lenses, but when they fail I get an HTTP 500 instead of the promised 400.
You forgot to add the ServerFilters.CatchLensFailure filter to your Server stack.

OpenAPI Contracts

When I use binary uploads, my OpenAPI endpoint receives no data.
With binary attachments, you need to ensure that the pre-flight validation does not eat the stream. You can do this by instructing http4k to ignore the incoming body for validation purposes - set preFlightExtraction = PreFlightExtraction.IgnoreBody in the route’s meta block.

Serverless

When using AWS Lambda, I get an "method is invalid" error when testing my lambda.
This comes from the fact that there are 2 different payload formats for AWS Lambda HTTP functions. We support both v1 and v2 formats, but recommend V2 is used as the JSON format is superior. To fix the problem, ensure that your Lambda function payload version matches the name of the AWS adapter function class being used (v1 or v2).

Still stuck on something?

Most questions get answered fastest in the #http4k channel on the Kotlin Slack - the maintainers are right there. Commercial queries go to the inbox.

scarf