Interface RequestBuilder<R>

Type Parameters:
R - The type the response body will be parsed into

@DoNotInherit public interface RequestBuilder<R>
A builder for HTTP requests and handling of their responses

Not for user extension, use HttpClient to get an instance

  • Method Details

    • withRequest

      RequestBuilder<R> withRequest(akka.http.javadsl.model.HttpRequest request)
    • addHeader

      RequestBuilder<R> addHeader(String header, String value)
    • addHeader

      RequestBuilder<R> addHeader(akka.http.javadsl.model.HttpHeader header)
    • withHeaders

      RequestBuilder<R> withHeaders(Iterable<akka.http.javadsl.model.HttpHeader> headers)
    • addCredentials

      RequestBuilder<R> addCredentials(akka.http.javadsl.model.headers.HttpCredentials credentials)
    • withTimeout

      RequestBuilder<R> withTimeout(Duration timeout)
    • addQueryParameter

      RequestBuilder<R> addQueryParameter(String key, String value)
    • modifyRequest

      RequestBuilder<R> modifyRequest(Function<akka.http.javadsl.model.HttpRequest,akka.http.javadsl.model.HttpRequest> adapter)
      Transform the request before sending it. This method allows for extra request configuration.
    • withRequestBody

      RequestBuilder<R> withRequestBody(Object object)
      Prepare for sending an HTTP request with an application/json body. The passed Object is serialized to json using the application's default Jackson serializer.
    • withRequestBody

      RequestBuilder<R> withRequestBody(String text)
      Prepare for sending an HTTP request with a text/plain body.
    • withRequestBody

      RequestBuilder<R> withRequestBody(byte[] bytes)
      Prepare for sending an HTTP request with an application/octet-stream body.
    • withRequestBody

      RequestBuilder<R> withRequestBody(akka.http.javadsl.model.ContentType type, byte[] bytes)
      Prepare for sending an HTTP request with an arbitrary payload encoded as described by the content type
    • withRetry

      RequestBuilder<R> withRetry(akka.pattern.RetrySettings retrySettings)
      Set the retry settings for this call.
      Parameters:
      retrySettings - The retry settings
    • withRetry

      RequestBuilder<R> withRetry(int maxRetries)
      Set the retry settings for this call. A predefined backoff strategy will be calculated based on the number of maxRetries.
      Parameters:
      maxRetries - The number of retries to make
    • invokeAsync

    • invoke

      StrictResponse<R> invoke()
    • responseBodyAs

      <T> RequestBuilder<T> responseBodyAs(Class<T> type)
      Converts the response body to the specified type.

      The response body payload is expected to be a JSON object and will be deserialized to the specified type using the application's default Jackson deserializer.

      Parameters:
      type - the expected class type of the response body
      Returns:
      a RequestBuilder configured to produce a StrictResponse with a deserialized response body of type T
    • responseBodyAsListOf

      <T> RequestBuilder<List<T>> responseBodyAsListOf(Class<T> elementType)
      Converts the response body as a list of the specified type.

      The response body payload is expected to be a JSON array and each element will be deserialized to the specified type using the application's default Jackson deserializer.

      Parameters:
      elementType - the expected class type of the response body
      Returns:
      a RequestBuilder configured to produce a StrictResponse with a deserialized response body of type T
    • parseResponseBody

      <T> RequestBuilder<T> parseResponseBody(Function<byte[],T> parse)
      Converts the response body to the specified type using the provided parser function.
      Parameters:
      parse - the function to parse the response body
      Returns:
      a RequestBuilder configured to produce a StrictResponse with a deserialized response body of type T