Class HTTPClient.Builder

java.lang.Object
org.apache.gravitino.client.HTTPClient.Builder
Enclosing class:
HTTPClient

public static class HTTPClient.Builder extends Object
Builder class for configuring and creating instances of HTTPClient.

This class allows for setting various configuration options for the HTTP client such as base URI, request headers, and ObjectMapper.

  • Method Details

    • uri

      public HTTPClient.Builder uri(String baseUri)
      Sets the base URI for the HTTP client.
      Parameters:
      baseUri - The base URI to be used for all HTTP requests.
      Returns:
      This Builder instance for method chaining.
    • withHeader

      public HTTPClient.Builder withHeader(String key, String value)
      Adds a single request header to the HTTP client.
      Parameters:
      key - The header name.
      value - The header value.
      Returns:
      This Builder instance for method chaining.
    • withHeaders

      public HTTPClient.Builder withHeaders(Map<String,String> headers)
      Adds multiple request headers to the HTTP client.
      Parameters:
      headers - A map of request headers (key-value pairs) to be included in all HTTP requests.
      Returns:
      This Builder instance for method chaining.
    • withObjectMapper

      public HTTPClient.Builder withObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Sets the custom ObjectMapper for the HTTP client.
      Parameters:
      objectMapper - The custom ObjectMapper to be used for request/response serialization.
      Returns:
      This Builder instance for method chaining.
    • withPreConnectHandler

      public HTTPClient.Builder withPreConnectHandler(Runnable beforeConnectHandler)
      Sets the preConnect handle for the HTTP client.
      Parameters:
      beforeConnectHandler - The handle run before connect to the server .
      Returns:
      This Builder instance for method chaining.
    • withAuthDataProvider

      public HTTPClient.Builder withAuthDataProvider(org.apache.gravitino.client.AuthDataProvider authDataProvider)
      Sets the AuthDataProvider for the HTTP client.
      Parameters:
      authDataProvider - The authDataProvider providing the data used to authenticate.
      Returns:
      This Builder instance for method chaining.
    • build

      public HTTPClient build()
      Builds and returns an instance of the HTTPClient with the configured options.
      Returns:
      An instance of HTTPClient with the configured options.