Package ctxhttp
Package ctxhttp provides helper functions for performing context-aware HTTP requests.
- func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error)
- func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error)
- func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error)
- func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error)
Package files
ctxhttp.go
In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.
The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.
Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.
func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
Do sends an HTTP request with the provided http.Client and returns
an HTTP response.
If the client is nil, http.DefaultClient is used.
The provided ctx must be non-nil. If it is canceled or times out,
ctx.Err() will be returned.
func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error)
Get issues a GET request via the Do function.
func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error)
Head issues a HEAD request via the Do function.
func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error)
Post issues a POST request via the Do function.
func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error)
PostForm issues a POST request via the Do function.