Documentation
¶
Overview ¶
Package httpclient provides a shared HTTP client for all external API calls. The client is safe for concurrent use and reuses connections. Call Init once during startup to set the timeout; the default is 10s.
Index ¶
Constants ¶
const MaxResponseSize = 1 << 20
MaxResponseSize limits HTTP response bodies to 1 MB to prevent OOM.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do executes an HTTP request using the shared client. The request's existing context.Context (if any) is respected; callers that want cancellation should attach one via http.Request.WithContext before calling.
func GetJSON ¶
GetJSON performs a GET request with context.Background and returns the response body. Prefer GetJSONCtx when a cancellable context is available (e.g. from Cobra's cmd.Context()).
func GetJSONCtx ¶ added in v0.3.0
GetJSONCtx performs a context-aware GET request and returns the response body. Returns an error for non-2xx status codes or on ctx cancellation.
Types ¶
This section is empty.