Documentation
¶
Overview ¶
Package httpclient provides a low-level HTTP client with configurable retry behaviour. It is the transport layer beneath internal/api and has no knowledge of Aura-specific concepts such as base URLs, API versions, or authentication.
Index ¶
Constants ¶
const (
// DefaultMaxResponseSize is the maximum size of response body to read (10MB).
DefaultMaxResponseSize = 10 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPResponse ¶
HTTPResponse stores the response from a request, including the payload and headers.
type HTTPService ¶
type HTTPService interface {
Get(ctx context.Context, url string, headers map[string]string) (*HTTPResponse, error)
Post(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
Put(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
Patch(ctx context.Context, url string, headers map[string]string, body string) (*HTTPResponse, error)
Delete(ctx context.Context, url string, headers map[string]string) (*HTTPResponse, error)
// Close releases idle connections held by the underlying HTTP transport.
// It should be called when the service is no longer needed.
Close()
}
HTTPService defines the interface for HTTP operations. This is the low-level HTTP layer that handles raw HTTP requests.
func NewHTTPService ¶
func NewHTTPService(timeout time.Duration, maxRetry int, logger *slog.Logger, customClient *http.Client) HTTPService
NewHTTPService creates a new HTTPService backed by a retryable HTTP client. Retries are attempted only on network-level errors (no response received); HTTP error responses (including 5xx) are always returned to the caller. The caller-supplied logger is used for debug output.
When customClient is non-nil it is used as the base http.Client inside the retryable wrapper (replacing the default transport). When nil the service constructs a default client with production-suitable connection pool settings.