update backend module to also use Ktor 2.0

This commit is contained in:
John O'Reilly 2021-12-18 13:51:33 +00:00
parent cd990acd39
commit 6d2e75146f
4 changed files with 10 additions and 22 deletions

View file

@ -16,8 +16,9 @@ dependencies {
with(Deps.Ktor) {
implementation(serverCore)
implementation(serverNetty)
//implementation(serialization)
implementation(websockets)
implementation(serverContentNegotiation)
implementation(json)
}
with(Deps.Log) {

View file

@ -2,14 +2,13 @@ import com.surrus.common.di.initKoin
import com.surrus.common.remote.Assignment
import com.surrus.common.remote.AstroResult
import com.surrus.common.remote.PeopleInSpaceApi
import io.ktor.application.*
import io.ktor.features.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.serialization.*
import io.ktor.server.application.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun main() {
val koin = initKoin(enableNetworkLogs = true).koin
@ -22,20 +21,6 @@ fun main() {
json()
}
install(CORS) {
method(HttpMethod.Options)
method(HttpMethod.Put)
method(HttpMethod.Delete)
method(HttpMethod.Patch)
header(HttpHeaders.Authorization)
header(HttpHeaders.ContentType)
header(HttpHeaders.AccessControlAllowOrigin)
// header("any header") if you want to add any header
allowCredentials = true
allowNonSimpleContentTypes = true
anyHost()
}
routing {
get("/astros.json") {

View file

@ -112,6 +112,8 @@ object Deps {
const val contentNegotiation = "io.ktor:ktor-client-content-negotiation:${Versions.ktor}"
const val json = "io.ktor:ktor-serialization-kotlinx-json:${Versions.ktor}"
const val serverContentNegotiation = "io.ktor:ktor-server-content-negotiation:${Versions.ktor}"
const val websockets = "io.ktor:ktor-websockets:${Versions.ktor}"
const val clientCore = "io.ktor:ktor-client-core:${Versions.ktor}"
const val clientJson = "io.ktor:ktor-client-json:${Versions.ktor}"

View file

@ -11,5 +11,5 @@ rootProject.name = "PeopleInSpace"
include(":app", ":common", ":compose-desktop")
include(":web")
include(":compose-web")
//include(":backend")
include(":backend")
include(":wearApp")