以 Ktor 快速打造 Web 應用 - 范 聖佑 === > 請從這裡開始 ## Ktor Framwork * 100% kotlin code * open source ## Install Plugin * Ktor * https://start.ktor.io ## Routing ``` kotlin routing { get("/") { call.resposeText("Hello world", ContentType.Text.Html, HttpStatusCode.OK) } } ``` ``` kotlin routing { get("/") { call.resposeText("Some json string...", ContentType.Application.json, HttpStatusCode.OK) } } ``` ## Template * Html DSL * FreeMarker ``` kotlin install(FreeMarker) { //... } ``` ## JSON API ``` kotlin install(ContentNegotiation) { jackson { } } ``` ``` kotlin call.respond(FreeMarkerContent("index.ftl", mapOf("task" to task), HttpStatusCode.OK) ``` ## Exposed DB * Kotlin SQL Library * DSL 語法 * DAO 模式 ``` kotlin Database.connect( // ... } ``` ## 相關資訊 * Talking Kotlin * ktor.guide ###### tags: `DevFest2019`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up