// Router get("/health").handler(createAsyncHandler(health(mongoClient), 500)) // HealthCheck fun health(mongoClient: MongoClient): suspend (RoutingContext) -> Unit = { try { val result = pingMongo(mongoClient) val json = getJsonResult(result) it.response().endWithJson(json) } catch (throwable: Throwable) { val errorObj = json { obj("error" to throwable.message) } it.response().statusCode = 500 it.response().endWithJson(errorObj) } } private suspend fun pingMongo(mongoClient: MongoClient): AsyncResult = runCommandAsync(mongoClient, "ping", json { obj("ping" to 1) })