Documentation
¶
Overview ¶
Package option carries the functional options that configure a bird.Client at construction and override settings for a single call.
client, _ := bird.NewClient(option.WithAPIKey(key)) msg, _ := client.Email.Send(ctx, params, option.WithMaxRetries(0))
Index ¶
- type RequestOption
- func WithAPIKey(key string) RequestOption
- func WithAPIVersion(version string) RequestOption
- func WithBaseURL(url string) RequestOption
- func WithEmailDefaults(d requestconfig.EmailDefaults) RequestOption
- func WithHTTPClient(client *http.Client) RequestOption
- func WithHeader(key, value string) RequestOption
- func WithIdempotencyKey(key string) RequestOption
- func WithMaxRetries(n int) RequestOption
- func WithRegion(region string) RequestOption
- func WithResponseInto(r *requestconfig.Response) RequestOption
- func WithTimeout(d time.Duration) RequestOption
- func WithWebhookSecret(secret string) RequestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RequestOption ¶
type RequestOption func(*requestconfig.Config) error
RequestOption configures a request. Options are applied in order, so a later option wins over an earlier one. Most options work at construction and per call; the client-only options (WithAPIKey, WithBaseURL, WithRegion, WithHTTPClient) return an error if applied to a single call.
func WithAPIKey ¶
func WithAPIKey(key string) RequestOption
WithAPIKey sets the API key used for Bearer authentication. The key's region prefix (bk_{region}_…) also selects the base URL unless WithBaseURL is set.
func WithAPIVersion ¶
func WithAPIVersion(version string) RequestOption
WithAPIVersion pins the API version, sent as the X-Bird-API-Version header. Off by default until the server honors it.
func WithBaseURL ¶
func WithBaseURL(url string) RequestOption
WithBaseURL overrides the base URL, bypassing region inference. Use it for a local or self-hosted server. Takes effect at client construction.
func WithEmailDefaults ¶
func WithEmailDefaults(d requestconfig.EmailDefaults) RequestOption
WithEmailDefaults sets values applied to every email send when the per-send params leave the corresponding field unset (the per-send value always wins).
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) RequestOption
WithHTTPClient supplies the underlying *http.Client. Per-attempt timeouts are applied through the request context, so leave the client's own Timeout unset.
func WithHeader ¶
func WithHeader(key, value string) RequestOption
WithHeader sets an extra request header, replacing any prior value for the key.
func WithIdempotencyKey ¶
func WithIdempotencyKey(key string) RequestOption
WithIdempotencyKey sets the idempotency key for a mutating call. When unset, one is generated and reused across that call's retries.
func WithMaxRetries ¶
func WithMaxRetries(n int) RequestOption
WithMaxRetries caps automatic retries of transient failures (timeouts, 429, 5xx). Zero disables retries.
func WithRegion ¶
func WithRegion(region string) RequestOption
WithRegion selects the region (e.g. "eu1") for base-URL resolution, overriding the API key's prefix. WithBaseURL takes precedence over both.
func WithResponseInto ¶
func WithResponseInto(r *requestconfig.Response) RequestOption
WithResponseInto captures the transport metadata (status, headers, request ID) of a single call into r, without changing the method's return signature.
func WithTimeout ¶
func WithTimeout(d time.Duration) RequestOption
WithTimeout sets the per-attempt timeout. Each retry gets a fresh budget.
func WithWebhookSecret ¶
func WithWebhookSecret(secret string) RequestOption
WithWebhookSecret sets the signing secret used by Client.Webhooks.Unwrap.