Documentation
¶
Index ¶
- Constants
- func CheckStatus(resp *http.Response, expected int, action string) error
- func DecodeResponseJSON(r io.Reader, out any, limit int64) error
- func DoJSON[T any](ctx context.Context, client *http.Client, method, endpoint string, body any, ...) (T, error)
- func DrainAndClose(resp *http.Response)
- func GunzipToBytes(r io.Reader, maxBytes int64) ([]byte, error)
- func NewHeaderTransport(base http.RoundTripper, headers http.Header) http.RoundTripper
- func ReadErrorMessage(r io.Reader, status string, limit int64) string
- func RequireClientAndURL(client *http.Client, base *url.URL) error
- func WrapError(prefix string, status string, r io.Reader) error
Constants ¶
View Source
const ( MaxErrorBodyBytes int64 = 2048 MaxJSONBodyBytes int64 = 1 << 20 MaxDownloadBodyBytes int64 = 64 << 20 MaxGunzipOutputBytes int64 = 256 << 20 )
Variables ¶
This section is empty.
Functions ¶
func DoJSON ¶
func DoJSON[T any](ctx context.Context, client *http.Client, method, endpoint string, body any, expectedStatus int, action string) (T, error)
DoJSON executes one bounded JSON request and requires exactly one expected status.
func DrainAndClose ¶
func NewHeaderTransport ¶
func NewHeaderTransport(base http.RoundTripper, headers http.Header) http.RoundTripper
NewHeaderTransport returns a transport that overlays headers without modifying the caller's request.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.