Documentation
¶
Overview ¶
Package requests is an elegant and simple HTTP library for golang, built for human beings.
This package mimics the implementation of the classic Python package Requests(https://requests.readthedocs.io/)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
Option is the functional option type.
func Form ¶
Form encode the given KV into the request body. It also sets the Content-Type as "application/x-www-form-urlencoded".
func FormPairs ¶
FormPairs returns an Form formed by the mapping of key, value ... Pairs panics if len(kv) is odd.
func HeaderPairs ¶
HeaderPairs returns an Headers formed by the mapping of key, value ... Pairs panics if len(kv) is odd.
func JSON ¶
func JSON(obj interface{}) Option
JSON serializes the given struct as JSON into the request body. It also sets the Content-Type as "application/json".
func ParamPairs ¶
ParamPairs returns an Params formed by the mapping of key, value ... Pairs panics if len(kv) is odd.
type Options ¶
type Options struct { Headers map[string]string Params map[string]string Form map[string]string JSON interface{} }
Options follow the design of Functional Options(https://github.com/tmrts/go-patterns/blob/master/idiom/functional-options.md)
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is a wrapper of http response.
func (*Response) Raw ¶
func (r *Response) Raw() io.ReadCloser
Raw get the raw socket response from the server.
func (*Response) StatusCode ¶
StatusCode get status code of http response.