httpx

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONContentType represents MIME type for JSON content.
	JSONContentType = "application/json"
)

Variables

View Source
var DefaultClient = &http.Client{
	Transport: DefaultTransport,
}

DefaultClient is the default Client and is used by Get, Head, and Post.

View Source
var DefaultTransport = &http.Transport{
	Proxy: http.ProxyFromEnvironment,
	Dial: (&net.Dialer{
		Timeout:   15 * time.Second,
		KeepAlive: 90 * time.Second,
	}).Dial,
	TLSHandshakeTimeout: 3 * time.Second,
}

DefaultTransport is the default implementation of Transport and is used by DefaultClient.

Functions

func Get

func Get(url string) (resp *http.Response, err error)

Get issues a GET to the specified URL.

func Head(url string) (resp *http.Response, err error)

Head issues a HEAD to the specified URL.

func Post

func Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

Post issues a POST to the specified URL.

func RealIP added in v1.3.3

func RealIP(r *http.Request) string

RealIP resolves the real client IP address from the request.

func WriteJSONResponse added in v1.7.1

func WriteJSONResponse(w http.ResponseWriter, code int, v interface{}) error

WriteJSONResponse encodes json content to the ResponseWriter.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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