go: github.com/shurcooL/go/ctxhttp Index | Files

package ctxhttp

import "github.com/shurcooL/go/ctxhttp"

Package ctxhttp provides helper functions for performing context-aware HTTP requests.

It's a copy of "golang.org/x/net/context/ctxhttp" with pre-1.7 support dropped, and "golang.org/x/net/context" import replaced with "context". It exists temporarily until "golang.org/x/net/context/ctxhttp" is updated, which will happen "in a couple releases" according to https://golang.org/cl/24620.

Index

Package Files

ctxhttp.go

func Do Uses

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 Uses

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 Uses

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 Uses

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.

Package ctxhttp imports 5 packages (graph) and is imported by 4 packages. Updated 2017-01-25. Refresh now. Tools for package owners.