Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // NoopTokenProvider is a token provider that returns an empty string which is ignored by `DoRequest`. NoopTokenProvider = TokenProvider(func() (token string, err error) { return "", nil }) )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
// Status is the HTTP status of the API response
Status int
// Header is the set of response headers
Header http.Header
// Response is the response body
Response []byte
}
APIError describes an error during unsuccessful HTTP request to an API
type BaseAPIClient ¶
type BaseAPIClient interface {
// GetBaseURL returns the base URL of the service which can be used in HTTP request tasks.
GetBaseURL() string
// DoRequest performs the HTTP request with the given parameters, marshals the payload and
// unmarshals the response into the given output if the status code is successful
DoRequest(ctx context.Context, method, path string, query url.Values, payload, out interface{}) error
}
BaseAPIClient describes all basic HTTP client operations required to work with a JSON API
func NewBaseAPIClient ¶
func NewBaseAPIClient(basePath, tokenHeaderName string, tokenProvider TokenProvider, client *http.Client, debug bool) BaseAPIClient
NewBaseAPIClient creates a new instance of the base API client implementation. Never use `debug=true` in production environments, it will leak sensitive data
type TokenProvider ¶
TokenProvider is a function that gets the token string for each request
func TokenProviderFromCreator ¶
func TokenProviderFromCreator(tc tokens.Creator, reference string, opts tokens.Options) TokenProvider
TokenProviderFromCreator creates a token provider out of token creator.
Click to show internal directories.
Click to hide internal directories.