Created
October 14, 2019 19:22
-
-
Save douglasalipio/4215185ee07bf53a8679a5f6f1524db8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.cabratech.canopus.api | |
import com.cabratech.canopus.api.data.SetupDataBase | |
import com.cabratech.canopus.api.data.setUp | |
import io.ktor.application.* | |
import io.ktor.response.* | |
import io.ktor.routing.* | |
import io.ktor.http.* | |
import io.ktor.http.content.* | |
import com.fasterxml.jackson.databind.* | |
import io.ktor.jackson.* | |
import io.ktor.features.* | |
import io.ktor.client.* | |
import io.ktor.client.engine.jetty.* | |
import org.koin.ktor.ext.Koin | |
fun main(args: Array<String>): 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) { | |
jackson { | |
enable(SerializationFeature.INDENT_OUTPUT) | |
} | |
} | |
val client = HttpClient(Jetty) { | |
} | |
routing { | |
get("/") { | |
call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain) | |
} | |
// Static feature. Try to access `/static/ktor_logo.svg` | |
static("/static") { | |
resources("static") | |
} | |
get("/json/jackson") { | |
call.respond(User()) | |
} | |
} | |
install(Koin) { | |
setUp() | |
} | |
} | |
data class User( | |
var name: String = "douglas", | |
var lastName: String = "mesquita", | |
var test: List<String> = listOf("1", "2") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment