withHttpClient
suspend fun <T> withHttpClient(httpClient: HttpClient? = null, expectSuccess: Boolean = false, block: suspend HttpClient.() -> T): T
Executes block with an HttpClient as the receiver. If httpClient is null, a new client is created and automatically closed after the block completes.
Return
the result of block
Parameters
httpClient
an optional pre-existing client to reuse; if null, a new client is created
expectSuccess
if true, non-2xx responses will throw exceptions (only applies to newly created clients)
block
the suspending block to execute with the client as receiver
Type Parameters
T
the return type of the block