服务器作为Kotlin的功能– http4k
服务器作为Kotlin的功能-http4k您是否听说过"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 服务器功能 written and published 通过 推特/Marius Eriksen. In the 科特林 world, the most prominent implementation of this concept is http4k, which the maintainers describe as an "用Kotlin编写的HTTP工具集,重点是创建简单的,可测试的API"。最好的部分是http4k应用程序只是我们可以直接测试的Kotlin函数。让我们看一下第一个示例:第一个http4k服务器示例val应用程序:HttpHandler = {request:Request->响应(OK).body(request.body)} val server = app.asServer(SunHttp(8000))。start()…