mirror of
				https://github.com/InsanusMokrassar/MicroUtils.git
				synced 2025-11-04 14:14:51 +00:00 
			
		
		
		
	new extension HttpResponse.bodyOrNullOnNoContent
This commit is contained in:
		@@ -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