Module methanol

Class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>>

java.lang.Object
com.github.mizosoft.methanol.Methanol.BaseBuilder<B>
Direct Known Subclasses:
Methanol.Builder, Methanol.WithClientBuilder
Enclosing class:
Methanol

public abstract static class Methanol.BaseBuilder<B extends Methanol.BaseBuilder<B>> extends Object
A base Methanol builder allowing to set the non-standard properties.
  • Method Details

    • apply

      public final B apply(Consumer<? super B> consumer)
      Calls the given consumer against this builder.
    • userAgent

      public B userAgent(String userAgent)
      Sets a default User-Agent header to use when sending requests.
      Throws:
      IllegalArgumentException - if userAgent is an invalid header value
    • baseUri

      public B baseUri(String uri)
      Sets the base URI with which each outgoing requests' URI is resolved.
    • baseUri

      public B baseUri(URI uri)
      Sets the base URI with which each outgoing requests' URI is resolved.
    • defaultHeader

      public B defaultHeader(String name, String value)
      Adds the given default header.
    • defaultHeaders

      public B defaultHeaders(String... headers)
      Adds each of the given default headers.
    • requestTimeout

      public B requestTimeout(Duration requestTimeout)
      Sets a default request timeout to use when not explicitly by an HttpRequest.
    • headersTimeout

      public B headersTimeout(Duration headersTimeout)
      Sets a timeout that will raise an HttpHeadersTimeoutException if all response headers aren't received within the timeout. Timeout events are scheduled using a system-wide ScheduledExecutorService.
    • headersTimeout

      public B headersTimeout(Duration headersTimeout, ScheduledExecutorService scheduler)
      Same as headersTimeout(Duration) but specifies a ScheduledExecutorService to use for scheduling timeout events.
    • readTimeout

      public B readTimeout(Duration readTimeout)
      Sets a default read timeout. Timeout events are scheduled using a system-wide ScheduledExecutorService.
    • readTimeout

      public B readTimeout(Duration readTimeout, ScheduledExecutorService scheduler)
      Sets a default readtimeout using the given ScheduledExecutorService for scheduling timeout events.
    • adapterCodec

      public B adapterCodec(AdapterCodec adapterCodec)
      Specifies the AdapterCodec with which request and response payloads are mapped.
    • autoAcceptEncoding

      public B autoAcceptEncoding(boolean autoAcceptEncoding)
      If enabled, each request will have an Accept-Encoding header appended, the value of which is the set of supported encodings. Additionally, each received response will be transparently decompressed by wrapping its BodyHandler with MoreBodyHandlers.decoding(BodyHandler).

      This value is true by default.

    • interceptor

      public B interceptor(Methanol.Interceptor interceptor)
      Adds an interceptor that is invoked right after the client receives a request. The interceptor receives the request before it is decorated (its URI resolved with the base URI, default headers added, etc...) or handled by an HttpCache.
    • backendInterceptor

      public B backendInterceptor(Methanol.Interceptor interceptor)
      Adds an interceptor that is invoked right before the request is forwarded to the client's backend. The interceptor receives the request after it is handled by all client interceptors, is decorated (its URI resolved with the base URI, default headers added, etc...) and finally handled by an HttpCache. This implies that backend interceptors aren't called if network isn't used, normally due to the presence of an HttpCache that is capable of serving a stored response.
    • postDecorationInterceptor

      @Deprecated(since="1.5.0") public B postDecorationInterceptor(Methanol.Interceptor interceptor)
    • build

      public Methanol build()
      Creates a new Methanol instance.