Class RatelimitedHttpClient

java.lang.Object
masecla.modrinth4j.client.HttpClient
masecla.modrinth4j.client.instances.RatelimitedHttpClient

public class RatelimitedHttpClient extends HttpClient
This class is used to connect to the Modrinth API with rate limiting.
  • Constructor Details

    • RatelimitedHttpClient

      public RatelimitedHttpClient(UserAgent userAgent, String apiKey)
      Creates a new instance of the client.
      Parameters:
      userAgent - The user agent to use.
      apiKey - The API key to use.
    • RatelimitedHttpClient

      public RatelimitedHttpClient(UserAgent userAgent, String baseUrl, String apiKey)
      Creates a new instance of the client.
      Parameters:
      userAgent - The user agent to use.
      baseUrl - The base URL to use.
      apiKey - The API key to use.
    • RatelimitedHttpClient

      public RatelimitedHttpClient(UserAgent userAgent, String baseUrl, String apiKey, long timeout)
      Creates a new instance of the client.
      Parameters:
      userAgent - The user agent to use.
      baseUrl - The base URL to use.
      apiKey - The API key to use.
      timeout - The timeout to use in milliseconds.
  • Method Details

    • nextRequest

      public CompletableFuture<Void> nextRequest()
      Returns the next request.
      Specified by:
      nextRequest in class HttpClient
      Returns:
      A future that completes when the next request is allowed.
    • interceptResponse

      public void interceptResponse(okhttp3.Response response)
      Intercepts the response.
      Overrides:
      interceptResponse in class HttpClient
      Parameters:
      response - - The response to intercept.