Documentation
¶
Index ¶
- Constants
- Variables
- func Get(url string) (resp *http.Response, err error)
- func Head(url string) (resp *http.Response, err error)
- func Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)
- func RealIP(r *http.Request) string
- func WriteJSONResponse(w http.ResponseWriter, code int, v interface{}) error
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 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.
Click to show internal directories.
Click to hide internal directories.