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);
}
Aggregations