val payload = mapOf("token" to slackToken, "email" to vm.get("email")) val r = post(url, data = payload) if (r.jsonObject.getBoolean("ok")) { call.respondText("{\"status\":1}", ContentType.Text.JavaScript) } else { when(r.jsonObject.getString("error")){ "already_invited" -> call.respondText("{\"status\":2}", ContentType.JavaScript) } } MainClass.kt
val error: String) val response = Response(“not-ok”, “bad params”) val gson = Gson() val json = gson.toJson(response) call.respondText(json, ContentType.Application.Json)