Server as a function with Kotlin – http4k

Server as a function with Kotlin – http4k

Functional Programming, Java, Kotlin, Software Development, Tutorial, Web
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()…
Read More
Web Applications with Kotlin ktor

Web Applications with Kotlin ktor

Functional Programming, Kotlin, Software Development, Web
Introduction Disclaimer: This ktor article was originally published in the Dzone Web Development Guide, which can be downloaded here. When Google made Kotlin an official language for Android a few months ago at Google I/O, the language gained much popularity in the Android world quickly. On the server side though, Kotlin is not as broadly adopted yet, and some people still seem to be cautious when backend services are involved. Other developers say that Kotlin is mature enough and we can safely use it for any server application in which Java could play a role otherwise. If you want to develop web apps with Kotlin, you can choose from various web frameworks like Spring MVC/WebFlux, Vert.x, Vaadin and basically everything available for the JVM. Besides the mentioned frameworks there's also…
Read More