Search in sources :

Example 1 with HTTPRequestDefinition

use of com.github.ljtfreitas.julian.http.HTTPRequestDefinition in project julian-http-client by ljtfreitas.

the class RxVertxHTTPClient method request.

@Override
public HTTPClientRequest request(HTTPRequestDefinition request) {
    RequestOptions options = new RequestOptions().setAbsoluteURI(request.path().toString()).setMethod(HttpMethod.valueOf(request.method().name())).setHeaders(request.headers().all().stream().reduce(MultiMap.caseInsensitiveMultiMap(), (m, h) -> m.add(h.name(), h.values()), (a, b) -> b));
    Flowable<Buffer> bodyAsFlowable = request.body().map(b -> FlowAdapters.toPublisher(b.serialize())).map(Flowable::fromPublisher).orElseGet(Flowable::empty).map(buf -> Buffer.buffer(buf.array()));
    return new VertxHTTPClientRequest(client, options, bodyAsFlowable);
}
Also used : HTTPClient(com.github.ljtfreitas.julian.http.client.HTTPClient) HTTPClientRequest(com.github.ljtfreitas.julian.http.client.HTTPClientRequest) FlowAdapters(org.reactivestreams.FlowAdapters) Flowable(io.reactivex.rxjava3.core.Flowable) HttpMethod(io.vertx.core.http.HttpMethod) Closeable(java.io.Closeable) MultiMap(io.vertx.core.MultiMap) HttpClient(io.vertx.rxjava3.core.http.HttpClient) RequestOptions(io.vertx.core.http.RequestOptions) IOException(java.io.IOException) Buffer(io.vertx.rxjava3.core.buffer.Buffer) HTTPRequestDefinition(com.github.ljtfreitas.julian.http.HTTPRequestDefinition) Buffer(io.vertx.rxjava3.core.buffer.Buffer) RequestOptions(io.vertx.core.http.RequestOptions) Flowable(io.reactivex.rxjava3.core.Flowable)

Aggregations

HTTPRequestDefinition (com.github.ljtfreitas.julian.http.HTTPRequestDefinition)1 HTTPClient (com.github.ljtfreitas.julian.http.client.HTTPClient)1 HTTPClientRequest (com.github.ljtfreitas.julian.http.client.HTTPClientRequest)1 Flowable (io.reactivex.rxjava3.core.Flowable)1 MultiMap (io.vertx.core.MultiMap)1 HttpMethod (io.vertx.core.http.HttpMethod)1 RequestOptions (io.vertx.core.http.RequestOptions)1 Buffer (io.vertx.rxjava3.core.buffer.Buffer)1 HttpClient (io.vertx.rxjava3.core.http.HttpClient)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 FlowAdapters (org.reactivestreams.FlowAdapters)1