Interface AsyncHttpClient

All Superinterfaces:
AutoCloseable, Closeable, io.micronaut.context.LifeCycle<AsyncHttpClient>
All Known Implementing Classes:
DefaultAsyncOverReactiveHttpClient

public interface AsyncHttpClient extends Closeable, io.micronaut.context.LifeCycle<AsyncHttpClient>
An HTTP client API that exposes asynchronous operations backed by the Java Future contract instead of Reactive Streams.
Since:
5.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default <I> CompletionStage<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>>
    exchange(io.micronaut.http.HttpRequest<I> request)
    Perform an HTTP request for the given request object emitting the full HTTP response.
    default <I,O> CompletionStage<io.micronaut.http.HttpResponse<O>>
    exchange(io.micronaut.http.HttpRequest<I> request, @Nullable io.micronaut.core.type.Argument<O> bodyType)
    Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
    <I,O,E> CompletionStage<io.micronaut.http.HttpResponse<O>>
    exchange(io.micronaut.http.HttpRequest<I> request, @Nullable io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
    Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
    default <I,O> CompletionStage<io.micronaut.http.HttpResponse<O>>
    exchange(io.micronaut.http.HttpRequest<I> request, Class<O> bodyType)
    Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
    default CompletionStage<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>>
    Perform an HTTP GET request for the given URI emitting the full HTTP response.
    default <O> CompletionStage<io.micronaut.http.HttpResponse<O>>
    exchange(String uri, Class<O> bodyType)
    Perform an HTTP GET request for the given URI emitting the full HTTP response and converting the response body to the specified type.
    default <I> CompletionStage<@Nullable String>
    retrieve(io.micronaut.http.HttpRequest<I> request)
    Perform an HTTP request and convert the response body to a String.
    default <I,O> CompletionStage<@Nullable O>
    retrieve(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType)
    Perform an HTTP request and convert the response body to the specified type.
    default <I,O,E> CompletionStage<@Nullable O>
    retrieve(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
    Perform an HTTP request and convert the response body to the specified type.
    default <I,O> CompletionStage<@Nullable O>
    retrieve(io.micronaut.http.HttpRequest<I> request, Class<O> bodyType)
    Perform an HTTP request and convert the response body to the specified type.
    default CompletionStage<@Nullable String>
    Perform an HTTP GET request for the given URI and convert the response body to a String.

    Methods inherited from interface io.micronaut.context.LifeCycle

    close, isRunning, refresh, start, stop
  • Method Details

    • exchange

      <I,O,E> CompletionStage<io.micronaut.http.HttpResponse<O>> exchange(io.micronaut.http.HttpRequest<I> request, @Nullable io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
      Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      E - The error type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      errorType - The error type
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • exchange

      default <I,O> CompletionStage<io.micronaut.http.HttpResponse<O>> exchange(io.micronaut.http.HttpRequest<I> request, @Nullable io.micronaut.core.type.Argument<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • exchange

      default <I> CompletionStage<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>> exchange(io.micronaut.http.HttpRequest<I> request)
      Perform an HTTP request for the given request object emitting the full HTTP response.
      Type Parameters:
      I - The request body type
      Parameters:
      request - The HttpRequest to execute
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • exchange

      default CompletionStage<io.micronaut.http.HttpResponse<io.micronaut.core.io.buffer.ByteBuffer<?>>> exchange(String uri)
      Perform an HTTP GET request for the given URI emitting the full HTTP response.
      Parameters:
      uri - The URI
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • exchange

      default <O> CompletionStage<io.micronaut.http.HttpResponse<O>> exchange(String uri, Class<O> bodyType)
      Perform an HTTP GET request for the given URI emitting the full HTTP response and converting the response body to the specified type.
      Type Parameters:
      O - The response body type
      Parameters:
      uri - The URI
      bodyType - The body type
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • exchange

      default <I,O> CompletionStage<io.micronaut.http.HttpResponse<O>> exchange(io.micronaut.http.HttpRequest<I> request, Class<O> bodyType)
      Perform an HTTP request for the given request object emitting the full HTTP response and converting the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      Returns:
      A CompletionStage that completes with the full HttpResponse
    • retrieve

      default <I,O,E> CompletionStage<@Nullable O> retrieve(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType, io.micronaut.core.type.Argument<E> errorType)
      Perform an HTTP request and convert the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      E - The error type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      errorType - The error type
      Returns:
      A CompletionStage that completes with the converted response body
    • retrieve

      default <I,O> CompletionStage<@Nullable O> retrieve(io.micronaut.http.HttpRequest<I> request, io.micronaut.core.type.Argument<O> bodyType)
      Perform an HTTP request and convert the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      Returns:
      A CompletionStage that completes with the converted response body
    • retrieve

      default <I,O> CompletionStage<@Nullable O> retrieve(io.micronaut.http.HttpRequest<I> request, Class<O> bodyType)
      Perform an HTTP request and convert the response body to the specified type.
      Type Parameters:
      I - The request body type
      O - The response body type
      Parameters:
      request - The HttpRequest to execute
      bodyType - The body type
      Returns:
      A CompletionStage that completes with the converted response body
    • retrieve

      default <I> CompletionStage<@Nullable String> retrieve(io.micronaut.http.HttpRequest<I> request)
      Perform an HTTP request and convert the response body to a String.
      Type Parameters:
      I - The request body type
      Parameters:
      request - The HttpRequest to execute
      Returns:
      A CompletionStage that completes with the converted response body
    • retrieve

      default CompletionStage<@Nullable String> retrieve(String uri)
      Perform an HTTP GET request for the given URI and convert the response body to a String.
      Parameters:
      uri - The URI
      Returns:
      A CompletionStage that completes with the converted response body