mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 14:47:15 +00:00
new extension HttpResponse.bodyOrNullOnNoContent
This commit is contained in:
parent
95be1a26f2
commit
a9f7fd8e32
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user