Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTransport ¶
ContextWithTransport returns a context with a http.RoundTripper for use as http.Client Transport
func TransportFromContext ¶
func TransportFromContext(ctx context.Context) http.RoundTripper
TransportFromContext returns an http.RoundTripper for use as http.Client Transport from the context or nil
Types ¶
type HTTPClient ¶
type HTTPClient interface {
// Get returns the body and media type of the URL using the provided context. The caller must close the body.
//
// This is optimized for easy content negotiation. Hence, the returned mediaType is stripped of qualifiers.
// e.g. "Content-Type: application/json; charset=utf-8" will return mediaType "application/json"
Get(ctx context.Context, url string, header http.Header) (body io.ReadCloser, mediaType string, err error)
// GetJSON is a convenience function that calls json.Unmarshal after Get.
GetJSON(ctx context.Context, url string, accept string, v interface{}) error
}
HTTPClient is a convenience wrapper for http.Client that consolidates common logic.
func New ¶
func New(transport http.RoundTripper) HTTPClient
New returns a client that implicitly authenticates when it needs to Use ContextWithTransport when testing.
Click to show internal directories.
Click to hide internal directories.