Documentation ¶
Overview ¶
status.go This package provides utility functions and structures for handling and categorizing HTTP error responses.
Index ¶
- func IsNonRetryableStatusCode(resp *http.Response) bool
- func IsPermanentRedirect(statusCode int) bool
- func IsRateLimitError(resp *http.Response) bool
- func IsRedirectStatusCode(statusCode int) bool
- func IsRetryableStatusCode(statusCode int) bool
- func IsTransientError(resp *http.Response) bool
- func TranslateStatusCode(resp *http.Response) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNonRetryableStatusCode ¶
IsNonRetryableStatusCode checks if the provided response indicates a non-retryable error.
func IsPermanentRedirect ¶ added in v0.0.97
IsPermanentRedirect checks if the provided HTTP status code is one of the permanent redirect codes.
func IsRateLimitError ¶
IsRateLimitError checks if the provided response indicates a rate limit error.
func IsRedirectStatusCode ¶ added in v0.0.97
IsRedirectStatusCode checks if the provided HTTP status code is one of the redirect codes. Redirect status codes instruct the client to make a new request to a different URI, as defined in the response's Location header.
- 301 Moved Permanently: The requested resource has been assigned a new permanent URI and any future references to this resource should use one of the returned URIs. - 302 Found: The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client should continue to use the Request-URI for future requests. - 303 See Other: The response to the request can be found under a different URI and should be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. - 307 Temporary Redirect: The requested resource resides temporarily under a different URI. The client should not change the request method if it performs an automatic redirection to that URI. - 308 Permanent Redirect: The request and all future requests should be repeated using another URI. 308 parallel the behavior of 301 but do not allow the HTTP method to change. So, for example, submitting a form to a permanently redirected resource may continue smoothly.
The function returns true if the statusCode is one of the above redirect statuses, indicating that the client should follow the redirection as specified in the Location header of the response.
func IsRetryableStatusCode ¶
IsRetryableStatusCode checks if the provided HTTP status code is considered retryable.
func IsTransientError ¶
IsTransientError checks if an error or HTTP response indicates a transient error.
func TranslateStatusCode ¶
TranslateStatusCode provides a human-readable message for HTTP status codes.
Types ¶
This section is empty.