mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-11-14 16:03:07 +00:00
new extension HttpResponse.bodyOrNullOnNoContent
This commit is contained in:
1 parent
95be1a26f2
commit
a9f7fd8e32
2 files changed
+5
No files matched your search
@@ -5,6 +5,7 @@
|
||||
* `Ktor`:
|
||||
* `Client`
|
||||
* `HttpResponse.bodyOrNull` now retrieve callback to check if body should be received or null
|
||||
* New extension `HttpResponse.bodyOrNullOnNoContent`
|
||||
|
||||
## 0.16.8
|
||||
|
||||
|
||||
@@ -7,3 +7,7 @@ import io.ktor.http.HttpStatusCode
|
||||
suspend inline fun <reified T : Any> HttpResponse.bodyOrNull(
|
||||
statusFilter: (HttpResponse) -> Boolean = { it.status == HttpStatusCode.OK }
|
||||
) = takeIf(statusFilter) ?.body<T>()
|
||||
|
||||
suspend inline fun <reified T : Any> HttpResponse.bodyOrNullOnNoContent() = bodyOrNull<T> {
|
||||
it.status != HttpStatusCode.NoContent
|
||||
}
|
||||
Reference in new issue
Block a user