Documentation ¶
Index ¶
- func HandleHTTPError(resp *http.Response) error
- func NewCachedClient(httpClient *http.Client, cacheTTL time.Duration) *http.Client
- func NewHTTPClient(opts ...ClientOption) *http.Client
- type Client
- type ClientOption
- func AddHeader(name, value string) ClientOption
- func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption
- func CacheResponse(ttl time.Duration, dir string) ClientOption
- func ReplaceTripper(tr http.RoundTripper) ClientOption
- func VerboseLog(out io.Writer, logTraffic bool, colorize bool) ClientOption
- type HTTPError
- type HTTPErrorItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleHTTPError ¶
func NewCachedClient ¶
func NewHTTPClient ¶
func NewHTTPClient(opts ...ClientOption) *http.Client
NewHTTPClient initializes an http.Client
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client facilitates making HTTP requests to the Instill API
func NewClientFromHTTP ¶
NewClientFromHTTP takes in an http.Client instance
type ClientOption ¶
type ClientOption = func(http.RoundTripper) http.RoundTripper
ClientOption represents an argument to NewClient
func AddHeader ¶
func AddHeader(name, value string) ClientOption
AddHeader turns a RoundTripper into one that adds a request header
func AddHeaderFunc ¶
AddHeaderFunc is an AddHeader that gets the string value from a function
func CacheResponse ¶
func CacheResponse(ttl time.Duration, dir string) ClientOption
CacheResponse produces a RoundTripper that caches HTTP responses to disk for a specified amount of time
func ReplaceTripper ¶
func ReplaceTripper(tr http.RoundTripper) ClientOption
ReplaceTripper substitutes the underlying RoundTripper with a custom one
func VerboseLog ¶
func VerboseLog(out io.Writer, logTraffic bool, colorize bool) ClientOption
VerboseLog enables request/response logging within a RoundTripper
Click to show internal directories.
Click to hide internal directories.