Skip to content

Commit

Permalink
Reduce nesting for json requests
Browse files Browse the repository at this point in the history
  • Loading branch information
BartArys committed Oct 28, 2020
1 parent ad62309 commit e2083c3
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ class KtorRequestHandler(
}

when (request) {
is JsonRequest -> {
request.body?.let {
val json = parser.encodeToString(it.strategy, it.body)
logger.debug { request.logString(json) }
this.body = TextContent(json, io.ktor.http.ContentType.Application.Json)
}
is JsonRequest -> run {
val requestBody = request.body ?: return@run
val json = parser.encodeToString(requestBody.strategy, requestBody.body)
logger.debug { request.logString(json) }
this.body = TextContent(json, io.ktor.http.ContentType.Application.Json)
}
is MultipartRequest -> {
val content = request.data
Expand Down

0 comments on commit e2083c3

Please sign in to comment.