Class 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 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. The handler will receive the response as an HttpResponse.

        In order to construct the request object with arbitrary parameters, pass a consumer to the requestConsumer argument 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 an HttpResponse through the returned Future.

        In order to construct the request object with arbitrary parameters, pass a consumer to the requestConsumer argument 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.