package com.kmalbz import io.ktor.application.* import io.ktor.response.* import io.ktor.request.* import io.ktor.routing.* import io.ktor.http.* import io.ktor.gson.* import io.ktor.features.* import io.ktor.client.* import io.ktor.client.engine.apache.* import com.fasterxml.jackson.databind.* import io.ktor.jackson.* import io.ktor.auth.* import kotlin.reflect.* import java.util.* import io.ktor.swagger.experimental.* fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) @Suppress("unused") // Referenced in application.conf @kotlin.jvm.JvmOverloads fun Application.module(testing: Boolean = false) { install(ContentNegotiation) { gson { } jackson { enable(SerializationFeature.INDENT_OUTPUT) } } val client = HttpClient(Apache) { } install(Authentication) { } routing { get("/") { call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain) } get("/json/gson") { call.respond(mapOf("hello" to "world")) } install(StatusPages) { exception { cause -> call.respond(HttpStatusCode.Unauthorized) } exception { cause -> call.respond(HttpStatusCode.Forbidden) } exception { cause -> call.respond(cause.code, cause.description) } } get("/json/jackson") { call.respond(mapOf("hello" to "world")) } OutputServiceRDBServer().apply { registerOutput() } } } class AuthenticationException : RuntimeException() class AuthorizationException : RuntimeException()