All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ufoscout.vertk.web.client.K.kt Maven / Gradle / Ivy

There is a newer version: 3.9.3
Show newest version
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