com.ufoscout.vertk.web.client.K.kt Maven / Gradle / Ivy
package com.ufoscout.vertk.web.client
import io.vertx.core.MultiMap
import io.vertx.core.buffer.Buffer
import io.vertx.core.json.JsonObject
import io.vertx.core.streams.ReadStream
import io.vertx.ext.web.client.HttpRequest
import io.vertx.ext.web.client.HttpResponse
import io.vertx.kotlin.coroutines.awaitResult
fun HttpRequest.putHeaders(vararg headers: Pair): HttpRequest {
headers.forEach { this.putHeader(it.first, it.second) }
return this
}
suspend fun HttpRequest.awaitSend(): HttpResponse {
return awaitResult> {
this.send(it)
}
}
suspend fun HttpRequest.awaitSendJson(body: Any): HttpResponse {
return awaitResult> {
this.sendJson(body, it)
}
}
suspend fun HttpRequest.awaitSendBuffer(body: Buffer): HttpResponse {
return awaitResult> {
this.sendBuffer(body, it)
}
}
suspend fun HttpRequest.awaitSendForm(body: MultiMap): HttpResponse {
return awaitResult> {
this.sendForm(body, it)
}
}
suspend fun HttpRequest.awaitSendJsonObject(body: JsonObject): HttpResponse {
return awaitResult> {
this.sendJsonObject(body, it)
}
}
suspend fun HttpRequest.awaitSendStream(body: ReadStream): HttpResponse {
return awaitResult> {
this.sendStream(body, it)
}
}
inline fun HttpResponse.bodyAsJson(): T {
return this.bodyAsJson(T::class.java)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy