From 2cc6126765cd331532a7cc2c55a352a76b15bd7e Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 6 Sep 2022 21:15:01 +0600 Subject: [PATCH 1/4] start 0.12.8 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc1baf3979a..3b8d726d8ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.12.8 + ## 0.12.7 * `Repos`: diff --git a/gradle.properties b/gradle.properties index 22ec9736793..b3d2f587601 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.12.7 -android_code_version=146 +version=0.12.8 +android_code_version=147 From ac58b6a7e32cd2283ddfaa5254fd7c5939ac58ae Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 6 Sep 2022 21:16:41 +0600 Subject: [PATCH 2/4] bodyOrNull/respondOrNoContent --- CHANGELOG.md | 6 ++++++ .../inmo/micro_utils/ktor/client/BodyOrNull.kt | 9 +++++++++ .../micro_utils/ktor/server/RespondOrNoContent.kt | 15 +++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt create mode 100644 ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/RespondOrNoContent.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b8d726d8ea..3809c8f8fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## 0.12.8 +* `Ktor`: + * `Client`: + * New extension `HttpClient#bodyOrNull` which returns `null` in case when server responded with `No Content` (204) + * `Server`: + * New extension `ApplicationCall#respondOrNoContent` which responds `No Content` (204) when passed data is null + ## 0.12.7 * `Repos`: diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt new file mode 100644 index 00000000000..55abf3b7c87 --- /dev/null +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/BodyOrNull.kt @@ -0,0 +1,9 @@ +package dev.inmo.micro_utils.ktor.client + +import io.ktor.client.call.body +import io.ktor.client.statement.HttpResponse +import io.ktor.http.HttpStatusCode + +suspend inline fun HttpResponse.bodyOrNull() = takeIf { + status == HttpStatusCode.OK +} ?.body() diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/RespondOrNoContent.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/RespondOrNoContent.kt new file mode 100644 index 00000000000..3bc770d1ede --- /dev/null +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/RespondOrNoContent.kt @@ -0,0 +1,15 @@ +package dev.inmo.micro_utils.ktor.server + +import io.ktor.http.HttpStatusCode +import io.ktor.server.application.ApplicationCall +import io.ktor.server.response.respond + +suspend inline fun ApplicationCall.respondOrNoContent( + data: T? +) { + if (data == null) { + respond(HttpStatusCode.NoContent) + } else { + respond(data) + } +} From 85d516d1e9d2c6689aa8a09baf30f6704152b813 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 6 Sep 2022 23:44:02 +0600 Subject: [PATCH 3/4] Update libs.versions.toml --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bb591d74a26..ddb4c3d7d0b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,14 +4,14 @@ kt = "1.7.10" kt-serialization = "1.4.0" kt-coroutines = "1.6.4" -jb-compose = "1.2.0-alpha01-dev764" +jb-compose = "1.2.0-alpha01-dev774" jb-exposed = "0.39.2" jb-dokka = "1.7.10" klock = "3.0.0" uuid = "0.5.0" -ktor = "2.1.0" +ktor = "2.1.1" gh-release = "2.4.1" From 4b13491a0e2095a19fae2d9cdaa646f79a635371 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 7 Sep 2022 00:56:48 +0600 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3809c8f8fd4..4eba7d2512f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.12.8 +* `Versions`: + * `Ktor`: `2.1.0` -> `2.1.1` + * `Compose`: `1.2.0-alpha01-dev764` -> `1.2.0-alpha01-dev774` * `Ktor`: * `Client`: * New extension `HttpClient#bodyOrNull` which returns `null` in case when server responded with `No Content` (204)