httpclient

package
v0.7.13-10-gf60fb541 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCachedClient

func NewCachedClient(httpClient *http.Client, cacheTTL time.Duration) *http.Client

func NewHTTPClient

func NewHTTPClient(io *iostreams.IOStreams, unixSocket string) (*http.Client, error)

generic authenticated HTTP client for commands

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client facilitates making HTTP requests to the GitHub API

func (*Client) HTTP

func (c *Client) HTTP() *http.Client

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

func AddHeaderFunc(name string, getValue func(*http.Request) (string, error)) ClientOption

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 ExtractHeader

func ExtractHeader(name string, dest *string) ClientOption

ExtractHeader extracts a named header from any response received by this client and, if non-blank, saves it to dest.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL