Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientTrace ¶
DefaultClientTrace returns a ClientTrace with all callbacks implemented using the provided Logger. Unused callbacks can be set to nil by the caller.
Types ¶
type Client ¶
type Client struct {
Host string // Base URL for Apple API
Development bool // Enable development mode
HTTPClient *http.Client // Underlying HTTP client
TokenProvider token.Provider // Responsible for providing tokens
Logger *slog.Logger // Structured logger
Trace *httptrace.ClientTrace // HTTP request trace hooks
}
Client represents an HTTP client with Apple authentication support.
func NewClient ¶
func NewClient(initializer HTTPClientInitializer, host string, tp token.Provider, opts ...Option) (*Client, error)
NewClient creates a new Client with a custom HTTP initializer and options.
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
CloseIdleConnections closes idle connections in the HTTP client.
type HTTPClientInitializer ¶ added in v0.1.1
HTTPClientInitializer is a function that returns a configured *http.Client.
func ConfigureHTTPClientInitializer ¶ added in v0.1.1
func ConfigureHTTPClientInitializer(cfg *HTTPConfig) HTTPClientInitializer
ConfigureHTTPClientInitializer returns an HTTP client configured based on the given HTTPConfig.
func DefaultHTTPClientInitializer ¶ added in v0.1.1
func DefaultHTTPClientInitializer() HTTPClientInitializer
DefaultHTTPClientInitializer returns a default HTTP client with TLS1.3 and HTTP/2 enabled.
type HTTPConfig ¶ added in v0.1.1
type HTTPConfig struct {
HTTPTimeout time.Duration // Maximum duration for a complete HTTP request
ReadIdleTimeout time.Duration // Idle period before sending an HTTP/2 PING frame
KeepAlive time.Duration // Interval for TCP keep-alive probes
DialTimeout time.Duration // Timeout for establishing new TCP connections
MaxConnsPerHost int // Maximum total connections per host (idle + active)
IdleConnTimeout time.Duration // Max time an idle connection is kept alive
MaxIdleConnsPerHost int // Maximum idle connections per host
TLSConfig *tls.Config // TLS settings for HTTPS connections
}
HTTPConfig defines transport and timeout settings used by clients.
func DefaultConfig ¶ added in v1.1.0
func DefaultConfig() HTTPConfig
GetDefaultConfigValue returns a copy of the default configuration. The returned configuration is independent, and modifications to it will not affect the package's internal state.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option defines a configurable option for Client, including its execution order.
func WithClientTimeout ¶ added in v0.1.1
WithClientTimeout sets a custom HTTP client timeout.
func WithClientTrace ¶
func WithClientTrace(f func(*slog.Logger) *httptrace.ClientTrace) Option
WithClientTrace sets a custom HTTP trace function.
func WithLogger ¶
WithLogger sets a custom structured logger.
func WithTransport ¶
func WithTransport(tr http.RoundTripper) Option
WithTransport sets a custom HTTP transport.
type OptionOrder ¶ added in v0.1.1
type OptionOrder int
OptionOrder defines the execution order for Client options. Options are applied in ascending order of these constants.
const ( Development OptionOrder = iota + 1 Logger Transport ClientTimeout ClientTrace // Depends on Logger being already set )
type UnixTime ¶ added in v1.0.0
UnixTime represents a time in milliseconds since Unix epoch (UTC).
func (UnixTime) MarshalJSON ¶ added in v1.0.0
MarshalJSON implements the json.Marshaler interface for UnixTime. It marshals the time into a Unix timestamp in milliseconds.
func (UnixTime) String ¶ added in v1.0.0
String returns the UnixTime as a formatted string (RFC3339Nano).
func (*UnixTime) UnmarshalJSON ¶ added in v1.0.0
UnmarshalJSON implements the json.Unmarshaler interface for UnixTime. It unmarshals a Unix timestamp in milliseconds into a UnixTime.