Documentation ¶
Overview ¶
response/error.go This package provides utility functions and structures for handling and categorizing HTTP error responses.
response/parse.go
status.go This package provides utility functions and structures for handling and categorizing HTTP error responses.
response/success.go
Responsible for handling successful API responses. It reads the response body, logs the raw response details,
and unmarshals the response based on the content type (JSON or XML).
Index ¶
- func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.SugaredLogger) error
- func IsNonRetryableStatusCode(statusCode int) bool
- func IsPermanentRedirect(statusCode int) bool
- func IsRedirectStatusCode(statusCode int) bool
- func IsRetryableStatusCode(statusCode int) bool
- func IsTransientError(statusCode int) bool
- type APIError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleAPISuccessResponse ¶ added in v0.1.14
func HandleAPISuccessResponse(resp *http.Response, out interface{}, sugar *zap.SugaredLogger) error
HandleAPISuccessResponse reads the response body, logs the raw response details, and unmarshals the response based on the content type.
func IsNonRetryableStatusCode ¶ added in v0.2.7
IsNonRetryableStatusCode checks if the provided response indicates a non-retryable error.
func IsPermanentRedirect ¶ added in v0.2.7
IsPermanentRedirect checks if the provided HTTP status code is one of the permanent redirect codes.
func IsRedirectStatusCode ¶ added in v0.2.7
IsRedirectStatusCode checks if the provided HTTP status code is one of the redirect codes.
func IsRetryableStatusCode ¶ added in v0.2.7
IsRetryableStatusCode checks if the provided HTTP status code is considered retryable.
func IsTransientError ¶ added in v0.2.7
IsTransientError checks if an error or HTTP response indicates a transient error.
Types ¶
type APIError ¶
type APIError struct { StatusCode int `json:"status_code"` // HTTP status code Method string `json:"method"` // HTTP method used for the request URL string `json:"url"` // The URL of the HTTP request Message string `json:"message"` // Summary of the error Details []string `json:"details,omitempty"` // Detailed error messages, if any RawResponse string `json:"raw_response"` // Raw response body for debugging }
APIError represents an api error response.
func HandleAPIErrorResponse ¶
func HandleAPIErrorResponse(resp *http.Response, sugar *zap.SugaredLogger) *APIError
HandleAPIErrorResponse handles the HTTP error response from an API and logs the error.