Skip to content

Commit

Permalink
Upgrade to ktor 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pambrose committed Dec 31, 2021
1 parent c48be92 commit bdeecd4
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10'
id "com.github.ben-manes.versions" version "0.39.0"
id "com.github.ben-manes.versions" version "0.40.0"
}

repositories {
Expand All @@ -16,16 +16,16 @@ sourceCompatibility = 1.8

description = 'battlesnake-quickstart'
group = 'io.battlesnake'
version = '0.12.1'
version = '0.13.0'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"

implementation "io.ktor:ktor-server:$ktor_version"
implementation "io.ktor:ktor-server-cio:$ktor_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-html-builder:$ktor_version"
implementation "io.ktor:ktor-serialization:$ktor_version"
implementation "io.ktor:ktor-server-html-builder:$ktor_version"
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"

testImplementation "io.ktor:ktor-server-tests:$ktor_version"

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ org.gradle.caching=true
junit_version=5.8.2
kluent_version=1.68
kotlin_version=1.6.10
ktor_version=1.6.7
logback_version=1.2.9
ktor_version=2.0.0-beta-1
logback_version=1.2.10
logging_version=2.1.21
serialization_version=1.3.2
slf4j_version=1.7.32
test_version=1.6.0
test_version=1.6.10
6 changes: 3 additions & 3 deletions src/main/kotlin/io/battlesnake/core/AbstractBattleSnake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ package io.battlesnake.core

import io.battlesnake.core.ktor.installs
import io.battlesnake.core.ktor.routes
import io.ktor.application.*
import io.ktor.features.*
import io.ktor.request.*
import io.ktor.server.application.*
import io.ktor.server.cio.*
import io.ktor.server.engine.*
import io.ktor.server.plugins.*
import io.ktor.server.request.*
import mu.KLogging
import java.util.concurrent.ConcurrentHashMap
import kotlin.time.measureTimedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package io.battlesnake.core

import io.ktor.application.*
import io.ktor.server.application.*
import kotlin.time.Duration

abstract class AbstractGameStrategy<T : SnakeContext>(private val verbose: Boolean = false) : GameStrategy<T>() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/io/battlesnake/core/GameStrategy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import io.battlesnake.core.GameStrategy.Companion.afterTurnMsg
import io.battlesnake.core.GameStrategy.Companion.describeMsg
import io.battlesnake.core.GameStrategy.Companion.endMsg
import io.battlesnake.core.GameStrategy.Companion.startMsg
import io.ktor.application.*
import io.ktor.features.*
import io.ktor.request.*
import io.ktor.server.application.*
import io.ktor.server.plugins.*
import io.ktor.server.request.*
import mu.KLogging
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/battlesnake/core/SnakeContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package io.battlesnake.core

import io.ktor.application.*
import io.ktor.server.application.*
import kotlin.time.Duration.Companion.nanoseconds
import kotlin.time.TimeSource

Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/io/battlesnake/core/ktor/Installs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

package io.battlesnake.core.ktor

import io.ktor.application.*
import io.ktor.features.*
import io.ktor.http.*
import io.ktor.request.*
import io.ktor.response.*
import io.ktor.serialization.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.*
import io.ktor.server.plugins.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import kotlinx.serialization.json.Json
import org.slf4j.event.Level

Expand All @@ -47,10 +47,10 @@ fun Application.installs() {
}

install(StatusPages) {
exception<AuthenticationException> {
exception<AuthenticationException> { call, cause ->
call.respond(HttpStatusCode.Unauthorized)
}
exception<AuthorizationException> {
exception<AuthorizationException> { call, cause ->
call.respond(HttpStatusCode.Forbidden)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/io/battlesnake/core/ktor/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import io.battlesnake.core.down
import io.battlesnake.core.left
import io.battlesnake.core.right
import io.battlesnake.core.up
import io.ktor.application.*
import io.ktor.html.*
import io.ktor.http.ContentType.Application.Json
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.application.*
import io.ktor.server.html.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlinx.html.Entities.nbsp
import kotlinx.html.HTMLTag
import kotlinx.html.a
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/battlesnake/java/ExampleSnake.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.battlesnake.core.MoveRequest;
import io.battlesnake.core.MoveResponse;
import io.battlesnake.core.SnakeContext;
import io.ktor.application.ApplicationCall;
import io.ktor.server.application.ApplicationCall;

import static io.battlesnake.core.JavaConstants.RIGHT;
import static io.battlesnake.java.ExampleSnake.MySnakeContext;
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/battlesnake/kotlin/DownSnake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import io.battlesnake.core.StartRequest
import io.battlesnake.core.down
import io.battlesnake.core.left
import io.battlesnake.core.strategy
import io.ktor.application.*
import io.ktor.server.application.*

object DownSnake : AbstractBattleSnake<DownSnake.MySnakeContext>() {

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/battlesnake/kotlin/ExampleSnake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.battlesnake.core.RIGHT
import io.battlesnake.core.SnakeContext
import io.battlesnake.core.strategy
import io.battlesnake.kotlin.ExampleSnake.MySnakeContext
import io.ktor.application.*
import io.ktor.server.application.*

object ExampleSnake : AbstractBattleSnake<MySnakeContext>() {

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/battlesnake/kotlin/PerimeterSnake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import io.battlesnake.core.SnakeContext
import io.battlesnake.core.StartRequest
import io.battlesnake.core.UP
import io.battlesnake.core.strategy
import io.ktor.application.*
import io.ktor.server.application.*

object PerimeterSnake : AbstractBattleSnake<PerimeterSnake.MySnakeContext>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import io.battlesnake.core.SnakeContext
import io.battlesnake.core.StartRequest
import io.battlesnake.core.UP
import io.battlesnake.core.strategy
import io.ktor.application.*
import io.ktor.server.application.*

object PerimiterListSnake : AbstractBattleSnake<PerimiterListSnake.MySnakeContext>() {

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/battlesnake/kotlin/SnakeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ import io.battlesnake.core.StartResponse
import io.battlesnake.core.You
import io.battlesnake.core.module
import io.battlesnake.core.strategy
import io.ktor.application.*
import io.ktor.http.HttpHeaders.ContentType
import io.ktor.http.HttpMethod.Companion.Get
import io.ktor.http.HttpMethod.Companion.Post
import io.ktor.http.HttpStatusCode.Companion.OK
import io.ktor.server.application.*
import io.ktor.server.testing.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand Down

0 comments on commit bdeecd4

Please sign in to comment.