Class RestTransportConfig

java.lang.Object
org.a2aproject.sdk.client.transport.spi.ClientTransportConfig<RestTransport>
org.a2aproject.sdk.client.transport.rest.RestTransportConfig

public class RestTransportConfig extends ClientTransportConfig<RestTransport>
Configuration for the REST transport protocol.

This configuration class allows customization of the HTTP client used for RESTful communication with A2A agents. If no HTTP client is specified, the default JDK-based implementation is used.

Basic usage:

// Use default HTTP client
RestTransportConfig config = new RestTransportConfigBuilder()
    .build();

Client client = Client.builder(agentCard)
    .withTransport(RestTransport.class, config)
    .build();

Custom HTTP client:

// Custom HTTP client with timeouts
A2AHttpClient customClient = new CustomHttpClient()
    .withConnectTimeout(Duration.ofSeconds(10))
    .withReadTimeout(Duration.ofSeconds(30));

RestTransportConfig config = new RestTransportConfigBuilder()
    .httpClient(customClient)
    .build();

With interceptors:

RestTransportConfig config = new RestTransportConfigBuilder()
    .httpClient(customClient)
    .addInterceptor(new LoggingInterceptor())
    .addInterceptor(new AuthInterceptor("Bearer token"))
    .build();
See Also:
  • Constructor Details

    • RestTransportConfig

      public RestTransportConfig()
      Create a REST transport configuration with the default HTTP client.

      The default JDK-based HTTP client will be used. Consider using RestTransportConfigBuilder instead for a more fluent API.

    • RestTransportConfig

      public RestTransportConfig(A2AHttpClient httpClient)
      Create a REST transport configuration with a custom HTTP client.

      Consider using RestTransportConfigBuilder instead for a more fluent API.

      Parameters:
      httpClient - the HTTP client to use for REST requests
  • Method Details

    • getHttpClient

      public @Nullable A2AHttpClient getHttpClient()
      Get the configured HTTP client.
      Returns:
      the HTTP client, or null if using the default