Idiomatic Kotlin Code / Vert.x


I have the following code:

put("/:database").coroutineHandler {
    Auth(keycloak, "realm:create").handle(it)
}.handler(BodyHandler.create()).coroutineHandler {
    Create(location, false).handle(it)

basically chaining 3 handlers, with the extension function coroutineHandler being defined as:

 * An extension method for simplifying coroutines usage with Vert.x Web routers.
private fun Route.coroutineHandler(fn: suspend (RoutingContext) -> Unit): Route {
    return handler { ctx ->
        launch(ctx.vertx().dispatcher()) {
            try {
            } catch (e: Exception) {

To me, this looks a bit ugly, but I’m new to Kotlin and Vert.x. Maybe a real CoroutineHandler defined as a suspending function would be nice, as normal Handlers are defined as follows (in Java):

public interface Handler<E> {
   * Something has happened, so handle it.
   * @param event  the event to handle
  void handle(E event);

The whole idea behind this chaining was, that first I want to do authorization checks, then add a BodyHandler for requests of any size, to PUT large files to a storage system (I hope that authorized users won’t kill their own storage-server) and then do the business logic stuff (for instance shredding the file into the internal binary representation of the storage system).

kind regards