Documentation
¶
Index ¶
- func HasStatusCode(err error, code int) bool
- func IsBadRequest(err error) bool
- func IsClientError(err error) bool
- func IsConflict(err error) bool
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- func IsServerError(err error) bool
- func IsUnauthorized(err error) bool
- func IsUnprocessableEntity(err error) bool
- type Client
- type ClientOption
- type ResponseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasStatusCode ¶ added in v0.7.0
HasStatusCode checks if the error is a ResponseError with the specified HTTP status code
func IsBadRequest ¶ added in v0.7.0
IsBadRequest checks if the error is a 400 Bad Request error
func IsClientError ¶ added in v0.7.0
IsClientError checks if the error is a 4xx client error
func IsConflict ¶ added in v0.7.0
IsConflict checks if the error is a 409 Conflict error
func IsForbidden ¶ added in v0.7.0
IsForbidden checks if the error is a 403 Forbidden error
func IsNotFound ¶ added in v0.7.0
IsNotFound checks if the error is a 404 Not Found error
func IsServerError ¶ added in v0.7.0
IsServerError checks if the error is a 5xx server error
func IsUnauthorized ¶ added in v0.7.0
IsUnauthorized checks if the error is a 401 Unauthorized error
func IsUnprocessableEntity ¶ added in v0.7.0
IsUnprocessableEntity checks if the error is a 422 Unprocessable Entity error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
type ClientOption ¶
type ClientOption func(*Client)
func WithBaseURL ¶
func WithBaseURL(baseURL url.URL) ClientOption
func WithRequestHeader ¶ added in v0.4.0
func WithRequestHeader(key, value string) ClientOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
type ResponseError ¶ added in v0.6.0
var ( // 4xx Client Errors ErrBadRequest ResponseError = ResponseError{Msg: "bad request", Code: http.StatusBadRequest} ErrPaymentRequired ResponseError = ResponseError{Msg: "payment required", Code: http.StatusPaymentRequired} ErrForbidden ResponseError = ResponseError{Msg: "forbidden", Code: http.StatusForbidden} ErrNotFound ResponseError = ResponseError{Msg: "resource not found", Code: http.StatusNotFound} ErrMethodNotAllowed ResponseError = ResponseError{Msg: "method not allowed", Code: http.StatusMethodNotAllowed} ErrNotAcceptable ResponseError = ResponseError{Msg: "not acceptable", Code: http.StatusNotAcceptable} ErrProxyAuthRequired ResponseError = ResponseError{Msg: "proxy authentication required", Code: http.StatusProxyAuthRequired} ErrRequestTimeout ResponseError = ResponseError{Msg: "request timeout", Code: http.StatusRequestTimeout} ErrConflict ResponseError = ResponseError{Msg: "conflict", Code: http.StatusConflict} ErrGone ResponseError = ResponseError{Msg: "gone", Code: http.StatusGone} ErrLengthRequired ResponseError = ResponseError{Msg: "length required", Code: http.StatusLengthRequired} ErrPreconditionFailed ResponseError = ResponseError{Msg: "precondition failed", Code: http.StatusPreconditionFailed} ErrRequestEntityTooLarge ResponseError = ResponseError{Msg: "request entity too large", Code: http.StatusRequestEntityTooLarge} ErrRequestURITooLong ResponseError = ResponseError{Msg: "request URI too long", Code: http.StatusRequestURITooLong} ErrUnsupportedMediaType ResponseError = ResponseError{Msg: "unsupported media type", Code: http.StatusUnsupportedMediaType} ErrRequestedRangeNotSatisfiable ResponseError = ResponseError{Msg: "requested range not satisfiable", Code: http.StatusRequestedRangeNotSatisfiable} ErrExpectationFailed ResponseError = ResponseError{Msg: "expectation failed", Code: http.StatusExpectationFailed} ErrTeapot ResponseError = ResponseError{Msg: "I'm a teapot", Code: http.StatusTeapot} ErrMisdirectedRequest ResponseError = ResponseError{Msg: "misdirected request", Code: http.StatusMisdirectedRequest} ErrUnprocessableEntity ResponseError = ResponseError{Msg: "unprocessable entity", Code: http.StatusUnprocessableEntity} ErrLocked ResponseError = ResponseError{Msg: "locked", Code: http.StatusLocked} ErrFailedDependency ResponseError = ResponseError{Msg: "failed dependency", Code: http.StatusFailedDependency} ErrTooEarly ResponseError = ResponseError{Msg: "too early", Code: http.StatusTooEarly} ErrUpgradeRequired ResponseError = ResponseError{Msg: "upgrade required", Code: http.StatusUpgradeRequired} ErrPreconditionRequired ResponseError = ResponseError{Msg: "precondition required", Code: http.StatusPreconditionRequired} ErrTooManyRequests ResponseError = ResponseError{Msg: "too many requests", Code: http.StatusTooManyRequests} ErrRequestHeaderFieldsTooLarge ResponseError = ResponseError{Msg: "request header fields too large", Code: http.StatusRequestHeaderFieldsTooLarge} // 5xx Server Errors ErrInternalServerError ResponseError = ResponseError{Msg: "internal server error", Code: http.StatusInternalServerError} ErrNotImplemented ResponseError = ResponseError{Msg: "not implemented", Code: http.StatusNotImplemented} ErrBadGateway ResponseError = ResponseError{Msg: "bad gateway", Code: http.StatusBadGateway} ErrGatewayTimeout ResponseError = ResponseError{Msg: "gateway timeout", Code: http.StatusGatewayTimeout} ErrHTTPVersionNotSupported ResponseError = ResponseError{Msg: "HTTP version not supported", Code: http.StatusHTTPVersionNotSupported} ErrVariantAlsoNegotiates ResponseError = ResponseError{Msg: "variant also negotiates", Code: http.StatusVariantAlsoNegotiates} ErrInsufficientStorage ResponseError = ResponseError{Msg: "insufficient storage", Code: http.StatusInsufficientStorage} ErrLoopDetected ResponseError = ResponseError{Msg: "loop detected", Code: http.StatusLoopDetected} ErrNotExtended ResponseError = ResponseError{Msg: "not extended", Code: http.StatusNotExtended} ErrNetworkAuthenticationRequired ResponseError = ResponseError{Msg: "network authentication required", Code: http.StatusNetworkAuthenticationRequired} )
func (ResponseError) Error ¶ added in v0.6.0
func (err ResponseError) Error() string
Click to show internal directories.
Click to hide internal directories.