mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 13:53:49 +00:00
improvements in HttpResponse.bodyOrNull
This commit is contained in:
parent
ef9b31aee0
commit
95be1a26f2
@ -2,6 +2,10 @@
|
||||
|
||||
## 0.16.9
|
||||
|
||||
* `Ktor`:
|
||||
* `Client`
|
||||
* `HttpResponse.bodyOrNull` now retrieve callback to check if body should be received or null
|
||||
|
||||
## 0.16.8
|
||||
|
||||
* `Versions`:
|
||||
|
@ -4,6 +4,6 @@ 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>()
|
||||
suspend inline fun <reified T : Any> HttpResponse.bodyOrNull(
|
||||
statusFilter: (HttpResponse) -> Boolean = { it.status == HttpStatusCode.OK }
|
||||
) = takeIf(statusFilter) ?.body<T>()
|
||||
|
Loading…
Reference in New Issue
Block a user