---
# System prepended metadata

title: 以 Ktor 快速打造 Web 應用 - 范 聖佑
tags: [DevFest2019]

---

以 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`
