Documentation ¶
Index ¶
- Constants
- func CheckResponse(res *http.Response, expected ...int) error
- func DecodeJSONBody(res *http.Response, j interface{}) error
- func ExtractLocation(res *http.Response, base string) (string, error)
- func ResolveReference(baseURI, referenceURI string) (string, error)
- type Client
- func NewClient(a auth.IAuthenticator) *Client
- func NewClientWithTransport(a auth.IAuthenticator, transport http.RoundTripper) *Client
- func NewInsecureTLSClient(a auth.IAuthenticator) *Client
- func NewTLSClient(a auth.IAuthenticator, certPaths []string) (*Client, error)
- func NewTestingHTTPClient(handler http.Handler) (cli *Client, closerFn func())
- type ProblemError
Constants ¶
const ( PollPeriod = 1 * time.Second MaxAttempts = 2 )
TODO(tho) make these two configurable
const ( APIStatusFailed = "failed" APIStatusSuccess = "success" APIStatusProcessing = "processing" APIStatusComplete = "complete" )
Variables ¶
This section is empty.
Functions ¶
func DecodeJSONBody ¶
func ExtractLocation ¶
Extract Location header and resolve it to the supplied base (if non-empty)
func ResolveReference ¶
Types ¶
type Client ¶
type Client struct { HTTPClient http.Client Auth auth.IAuthenticator }
Client holds configuration data associated with the HTTP(s) session, and a reference to an IAuthenticator that is used to provide Authorization headers for requests.
func NewClient ¶
func NewClient(a auth.IAuthenticator) *Client
NewClient instantiates a new Client with a fixed 5s timeout. The client will use the provided IAuthenticator for requests, if it is not nil.
func NewClientWithTransport ¶ added in v0.3.0
func NewClientWithTransport(a auth.IAuthenticator, transport http.RoundTripper) *Client
NewClientWithTransport instantiates a new Client with the specified transport and a fixed 5s timeout. The client will use the provided IAuthenticator for requests, if it is not nil.
func NewInsecureTLSClient ¶ added in v0.3.0
func NewInsecureTLSClient(a auth.IAuthenticator) *Client
NewInsecureTLSClient instantiates a new Client with a transport configured to accept TLS connections without verifying certs and a fixed 5s timeout. The client will use the provided IAuthenticator for requests, if it is not nil.
func NewTLSClient ¶ added in v0.3.0
func NewTLSClient(a auth.IAuthenticator, certPaths []string) (*Client, error)
NewTLSClient instantiates a new Client with a fixed 5s timeout and transport configured with the system certificate pool as well as any certs provided. The client will use the provided IAuthenticator for requests, if it is not nil.
func NewTestingHTTPClient ¶
NewTestingHTTPClient creates an HTTP test server (with a configurable request handler), an API Client and connects them together. The API client and the server's shutdown switch are returned.
func (Client) DeleteResource ¶
func (Client) GetResource ¶ added in v0.1.0
func (Client) PostEmptyResource ¶ added in v0.1.0
type ProblemError ¶ added in v0.1.0
type ProblemError struct {
problems.DefaultProblem
}
func (*ProblemError) Error ¶ added in v0.1.0
func (o *ProblemError) Error() string