mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-23 09:07:14 +00:00
commit
e3d3cacfa4
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,5 +1,16 @@
|
||||
# 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
|
||||
|
||||
* `Repos`:
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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>()
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user