Global options are passed when initializing the SDK client and apply to all operations.
WithServerURL allows providing an alternative server URL.
sfc.WithServerURL("https://api.example.com")WithTemplatedServerURL allows providing an alternative server URL with templated parameters.
sfc.WithTemplatedServerURL("https://{host}:{port}", map[string]string{
"host": "api.example.com",
"port": "8080",
})WithServerIndex allows the overriding of the default server by index.
sfc.WithServerIndex(1)WithClient allows the overriding of the default HTTP client used by the SDK.
sfc.WithClient(httpClient)WithSecurity configures the SDK to use the provided security details.
sfc.WithSecurity(/* ... */)WithSecuritySource configures the SDK to invoke the provided function on each method call to determine authentication.
sfc.WithSecuritySource(/* ... */)WithRetryConfig allows setting the default retry configuration used by the SDK for all supported operations.
sfc.WithRetryConfig(retry.Config{
Strategy: "backoff",
Backoff: retry.BackoffStrategy{
InitialInterval: 500 * time.Millisecond,
MaxInterval: 60 * time.Second,
Exponent: 1.5,
MaxElapsedTime: 5 * time.Minute,
},
RetryConnectionErrors: true,
})WithTimeout sets the default request timeout for all operations.
sfc.WithTimeout(30 * time.Second)Per-method options are passed as the last argument to individual methods and override any global settings for that request.
WithServerURL allows providing an alternative server URL for a single request.
operations.WithServerURL("http://api.example.com")WithTemplatedServerURL allows providing an alternative server URL with templated parameters for a single request.
operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{
"host": "api.example.com",
"port": "8080",
})WithRetries allows customizing the default retry configuration for a single request.
operations.WithRetries(retry.Config{
Strategy: "backoff",
Backoff: retry.BackoffStrategy{
InitialInterval: 500 * time.Millisecond,
MaxInterval: 60 * time.Second,
Exponent: 1.5,
MaxElapsedTime: 5 * time.Minute,
},
RetryConnectionErrors: true,
})WithOperationTimeout allows setting the request timeout for a single request.
operations.WithOperationTimeout(30 * time.Second)WithSetHeaders allows setting custom headers on a per-request basis. If the request already contains headers matching the provided keys, they will be overwritten.
operations.WithSetHeaders(map[string]string{
"X-Cache-TTL": "60",
})WithURLOverride allows overriding the default URL for an operation.
operations.WithURLOverride("/custom/path")