Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbull committed Apr 15, 2022
1 parent ea9298c commit 96a84b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
object Versions {
const val dokka = "1.6.10"
const val kotlin = "1.6.10"
const val kotlinBenchmark = "0.4.1"
const val kotlinCoroutines = "1.6.0"
const val ktor = "2.0.0-beta-1"
const val dokka = "1.6.20"
const val kotlin = "1.6.20"
const val kotlinBenchmark = "0.4.2"
const val kotlinCoroutines = "1.6.1"
const val ktor = "2.0.0"
const val logback = "1.2.3"
const val versionsPlugin = "0.41.0"
}
2 changes: 1 addition & 1 deletion example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ dependencies {
implementation(project(":kotlin-result"))
implementation(kotlin("stdlib-jdk8"))
implementation("ch.qos.logback:logback-classic:${Versions.logback}")
implementation("io.ktor:ktor-serialization-jackson:${Versions.ktor}")
implementation("io.ktor:ktor-server-core:${Versions.ktor}")
implementation("io.ktor:ktor-server-content-negotiation:${Versions.ktor}")
implementation("io.ktor:ktor-serialization-jackson:${Versions.ktor}")
implementation("io.ktor:ktor-server-netty:${Versions.ktor}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import io.ktor.server.application.call
import io.ktor.server.application.install
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.server.plugins.ContentNegotiation
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.request.receive
import io.ktor.server.response.respond
import io.ktor.server.routing.get
Expand All @@ -46,8 +46,8 @@ import io.ktor.server.routing.routing

fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
configureRouting()
configureSerialization()
configureRouting()
}.start(wait = true)
}

Expand All @@ -73,15 +73,17 @@ fun Application.configureRouting() {

routing {
get("/customers/{id}") {
val (status, message) = call.parameters.readId()
val (status, message) = call.parameters
.readId()
.andThen(customerService::getById)
.mapBoth(::customerToResponse, ::messageToResponse)

call.respond(status, message)
}

post("/customers/{id}") {
val (status, message) = call.parameters.readId()
val (status, message) = call.parameters
.readId()
.andThen { customerService.save(it, call.receive()) }
.mapBoth(::eventToResponse, ::messageToResponse)

Expand All @@ -95,9 +97,7 @@ fun Application.configureRouting() {
}

private fun Parameters.readId(): Result<Long, DomainMessage> {
return get("id")
?.toLongOrNull()
.toResultOr { CustomerRequired }
return get("id")?.toLongOrNull().toResultOr { CustomerRequired }
}

private fun customerToResponse(customer: CustomerDto) = HttpStatusCode.OK to customer
Expand Down

0 comments on commit 96a84b2

Please sign in to comment.