Module com.zerodeplibs.webpush
Class VertxWebClientRequestPreparer
- java.lang.Object
-
- com.zerodeplibs.webpush.httpclient.VertxWebClientRequestPreparer
-
public class VertxWebClientRequestPreparer extends Object
The "Preparer" used to utilize Vert.x Web Client.
Thread Safety:Instances of this class are immutable. So they can be accessed safely from multiple threads.
- Author:
- Tomoki Sato
- See Also:
PreparerBuilder
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PreparerBuilder<VertxWebClientRequestPreparer>getBuilder()Gets a newPreparerBuilderused to constructVertxWebClientRequestPreparer.io.vertx.core.Future<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>sendBuffer(io.vertx.ext.web.client.WebClient webClient, Consumer<io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer>> requestConsumer)Send a request with the givenwebClient.voidsendBuffer(io.vertx.ext.web.client.WebClient webClient, Consumer<io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer>> requestConsumer, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>> handler)Send a request with the givenwebClient.
-
-
-
Method Detail
-
sendBuffer
public void sendBuffer(io.vertx.ext.web.client.WebClient webClient, Consumer<io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer>> requestConsumer, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>>> handler)Send a request with the given
webClient. Thehandlerwill receive the response as anHttpResponse.In order to construct the request object with arbitrary parameters, pass a consumer to the
requestConsumerargument like:preparer.sendBuffer( webClient, request -> { request.timeout(10_000L) }, response -> { ... } )- Parameters:
webClient- the web client used to create an HTTP request.requestConsumer- the consumer used to set arbitrary parameters.handler- the handler receiving the response.- See Also:
HttpRequest.sendBuffer(Buffer, Handler)
-
sendBuffer
public io.vertx.core.Future<io.vertx.ext.web.client.HttpResponse<io.vertx.core.buffer.Buffer>> sendBuffer(io.vertx.ext.web.client.WebClient webClient, Consumer<io.vertx.ext.web.client.HttpRequest<io.vertx.core.buffer.Buffer>> requestConsumer)Send a request with the given
webClient. If the request succeeds, the response is available as anHttpResponsethrough the returnedFuture.In order to construct the request object with arbitrary parameters, pass a consumer to the
requestConsumerargument like:preparer.sendBuffer( webClient, request -> { request.timeout(10_000L) } )- Parameters:
webClient- the web client used to create an HTTP request.requestConsumer- the consumer used to set arbitrary parameters.- Returns:
- the future result of the request.
-
getBuilder
public static PreparerBuilder<VertxWebClientRequestPreparer> getBuilder()
Gets a newPreparerBuilderused to constructVertxWebClientRequestPreparer.- Returns:
- a new
PreparerBuilderused to constructVertxWebClientRequestPreparer.
-
-