Merge pull request #186 from InsanusMokrassar/0.12.8

0.12.8
This commit is contained in:
InsanusMokrassar 2022-09-07 00:57:17 +06:00 committed by GitHub
commit e3d3cacfa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 4 deletions

View File

@ -1,5 +1,16 @@
# Changelog # Changelog
## 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)
* `Server`:
* New extension `ApplicationCall#respondOrNoContent` which responds `No Content` (204) when passed data is null
## 0.12.7 ## 0.12.7
* `Repos`: * `Repos`:

View File

@ -14,5 +14,5 @@ crypto_js_version=4.1.1
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.12.7 version=0.12.8
android_code_version=146 android_code_version=147

View File

@ -4,14 +4,14 @@ kt = "1.7.10"
kt-serialization = "1.4.0" kt-serialization = "1.4.0"
kt-coroutines = "1.6.4" 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-exposed = "0.39.2"
jb-dokka = "1.7.10" jb-dokka = "1.7.10"
klock = "3.0.0" klock = "3.0.0"
uuid = "0.5.0" uuid = "0.5.0"
ktor = "2.1.0" ktor = "2.1.1"
gh-release = "2.4.1" gh-release = "2.4.1"

View File

@ -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 <reified T : Any> HttpResponse.bodyOrNull() = takeIf {
status == HttpStatusCode.OK
} ?.body<T>()

View File

@ -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 <reified T : Any> ApplicationCall.respondOrNoContent(
data: T?
) {
if (data == null) {
respond(HttpStatusCode.NoContent)
} else {
respond(data)
}
}