Annotation Interface Client


Allows defining declarative HTTP clients and customizing injection for injecting HttpClient implementations.
Since:
1.0
Author:
Graeme Rocher
  • Element Details

    • value

      @AliasFor(member="id") String value
      Returns:
      The URL or service ID of the remote service
      Default:
      ""
    • id

      @AliasFor(member="value") String id
      Returns:
      The ID of the client
      Default:
      ""
    • definitionType

      The interface definition type. When set to DefinitionType.SERVER the Produces and Consumes definition evaluated for each method of the interface will be reversed .

      Whilst not necessarily recommended, there are scenarios like testing where it is useful to share a common interface between client and server and use the interface to create a new client declarative client. The client typically needs to produce the content type accepted by the server and consume the content type produced by the server. In this arrangement using the interface directly will not result in the correct behaviour.

      In this scenario you can set Client.DefinitionType to DefinitionType.SERVER which will ensure the requests sent by the client use the content type declared by the Consumes annotation of the interface and that responses use the content type declared by the Produces.

      The default behaviour is to use DefinitionType.CLIENT where the inverse of the above is true.

      Returns:
      The interface definition type
      Since:
      4.8.0
      See Also:
      Default:
      CLIENT
    • path

      String path
      The base URI for the client. Only to be used in conjunction with id().
      Returns:
      The base URI
      Default:
      ""
    • errorType

      Class<?> errorType
      Returns:
      The type used to decode errors
      Default:
      io.micronaut.http.hateoas.JsonError.class
    • configuration

      Class<? extends HttpClientConfiguration> configuration
      Returns:
      The http client configuration bean to use
      Default:
      io.micronaut.http.client.HttpClientConfiguration.class
    • httpVersion

      Deprecated.
      There are now separate settings for HTTP and HTTPS connections. To configure HTTP connections (e.g. for h2c), use plaintextMode(). To configure ALPN, set alpnModes().
      The HTTP version.
      Returns:
      The HTTP version of the client.
      Default:
      HTTP_1_1
    • plaintextMode

      The connection mode to use for plaintext (http as opposed to https) connections.
      Note: If httpVersion() is set, this setting is ignored!
      Returns:
      The plaintext connection mode.
      Since:
      4.0.0
      Default:
      HTTP_1
    • alpnModes

      @NonNull @NonNull String[] alpnModes
      The protocols to support for TLS ALPN. If HTTP 2 is included, this will also restrict the TLS cipher suites to those supported by the HTTP 2 standard.
      Note: If httpVersion() is set, this setting is ignored!
      Returns:
      The supported ALPN protocols.
      Since:
      4.0.0
      Default:
      {"h2", "http/1.1"}