Use custom HTTP Clients
The SDKs will be default use their own HTTP Client instance created at runtime. But it is also possible to configure the SDK to use a custom HTTP Client instance, provided to it when the SDK is initialised. This allows you to use HTTP Clients that may be setup to use proxies, provide custom telemetry or be preconfigured with global headers or configuration.
- Go
- Python
- Typescript
- Java
The Go SDK will accept a client that provides the same interface as the standard library's http.Client
// Your custom HTTP Client
c := &http.Client{}
opts := []sdk.SDKOption{
sdk.WithClient(c),
}
s := sdk.New(opts)
The Python SDK will accept a client from the requests
package: https://requests.readthedocs.io/en/latest/
s = sdk.SDK()
# Your custom HTTP Client
client = requests.Session()
s.config_client(client)
The Typescript SDK will accept a client from the axios
package: https://axios-http.com/docs/intro
// Your custom HTTP Client
const client = axios.create();
const opts = [WithClient(client)];
const s = new SDK(opts);
The Java SDK will accept a client that implements the HTTPClient
interface in the utils
package. This will wrap a java.net.http.HttpClient
instance and the call to send
.
// Your custom HTTP Client
YouHttpClient client = new YourHttpClient();
SDK.Builder builder = SDK.builder();
builder.setClient(client);
SDK sdk = builder.build();