Documentation ¶
Index ¶
Constants ¶
const (
// MIMETypeJSON defines the MIME type for JSON documents.
MIMETypeJSON = "application/json"
)
Variables ¶
This section is empty.
Functions ¶
func WrapURLError ¶
WrapURLError is a helper to add an end-user message to trasnport errros.
Resty doesn't provide a hook for errors in `http.Client.Do`, e.g. if the connector configuration contains an invalid URL. This wrapper offers clients a way to handle such cases:
if _, err := httpclient.New(name, host).R().Post(url); err != nil { return nil, httpclient.WrapURLError(err) }
Types ¶
type Client ¶
type Client struct { *resty.Client // contains filtered or unexported fields }
Client performs HTTP requests for connectors, implementing error handling and logging in a consistent way.
type ErrBody ¶
type ErrBody interface {
Message() string
}
ErrBody allows Client to extract an error message from the API.
type Option ¶
type Option func(*Client)
Option provides configuration options for a client.
func WithEndUserError ¶
WithEndUserError will unmarshal error response bodies as the error struct and will use their message as an end-user error.
func WithLogger ¶
WithLogger will use the provider logger to log the request and response information.