Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
NewRequest(ctx context.Context, method, prefix, urlPath string, body interface{}) (*http.Request, error)
Do(req *http.Request, obj interface{}) error
With(modifiers ...ClientModifierFn) Client
}
Client is an HTTP client for communicating with Upbound.
type ClientModifierFn ¶
type ClientModifierFn func(*HTTPClient)
A ClientModifierFn modifies an HTTP client.
type Config ¶
type Config struct {
// Client is the underlying client.
Client Client
// Logger is the interface for structured logging.
Logger logging.Logger
}
Config represents common configuration for Upbound SDK clients.
func NewConfig ¶
func NewConfig(modifiers ...ConfigModifierFn) *Config
NewConfig builds a new Config for communicating with the Upbound API.
type DefaultErrorHandler ¶
type DefaultErrorHandler struct{}
DefaultErrorHandler is the default operations for handling errors returned by the Upbound API.
type HTTPClient ¶
type HTTPClient struct {
// BaseURL is the base Upbound API URL.
BaseURL *url.URL
// ErrorHandler controls how the client handles errors.
ErrorHandler ResponseErrorHandler
// HTTP is the underlying HTTP client.
HTTP *http.Client
// User agent for communicating with the Upbound API.
UserAgent string
}
HTTPClient implements the Client interface and allows for overriding of base URL, error handling, and user agent.
func NewClient ¶
func NewClient(modifiers ...ClientModifierFn) *HTTPClient
NewClient builds a new default HTTP client for Upbound.
func (*HTTPClient) Do ¶
func (c *HTTPClient) Do(req *http.Request, obj interface{}) error
Do performs an HTTP request and reads the body into the provided interface.
func (*HTTPClient) NewRequest ¶
func (c *HTTPClient) NewRequest(ctx context.Context, method, prefix, urlPath string, body interface{}) (*http.Request, error)
NewRequest builds an HTTP request.
func (*HTTPClient) With ¶ added in v0.3.0
func (c *HTTPClient) With(modifiers ...ClientModifierFn) Client
With returns a new Client after applying given modifiers.
type ResponseErrorHandler ¶
A ResponseErrorHandler handles errors in HTTP responses.