Server as a function with Kotlin – http4k
Server as a function with Kotlin - http4k Have you ever heard about the concept of "Server as a Function"? The idea is that we write our server application based on just ordinary functions, which is based on a concept outlined in the paper Your Server as a Function written and published by Twitter/Marius Eriksen. In the Kotlin world, the most prominent implementation of this concept is http4k, which the maintainers describe as an "HTTP toolset written in Kotlin with a focus on creating simple, testable APIs". The best part about it is that http4k applications are just Kotlin functions that we can test straightforwardly. Take a look at this first example: First http4k server example val app: HttpHandler = { request: Request -> Response(OK).body(request.body) } val server = app.asServer(SunHttp(8000)).start()…