Versions in this module Expand all Collapse all v0 v0.0.1 Nov 12, 2021 Changes in this version + const Version + var ApplicationFormURLEncoded = NewContentType("application/x-www-form-urlencoded") + var ApplicationJSON = NewContentType("application/json") + var ApplicationOctetStream = NewContentType("application/octet-stream") + var ApplicationXML = NewContentType("application/xml") + var DefaultClient = newDefaultClient + var DefaultContentType = ApplicationFormURLEncoded + var DefaultHeaders = map[string]string + var DefaultRedirectLimit = 10 + var DefaultReqHooks []Hook + var DefaultTimeout = time.Second * 10 + var DefaultTransport http.RoundTripper = transport() + var DefaultUserAgent = "go-request/" + Version + var ErrMaxRedirect = errors.New("exceeded max redirects") + var MultipartFormData = NewContentType("multipart/form-data") + var TextHTML = NewContentType("text/html") + var TextPlain = NewContentType("text/plain") + var TextXML = NewContentType("text/xml") + type Args struct + BasicAuth BasicAuth + Body io.Reader + Client *http.Client + Cookies map[string]string + Files []FileField + FormData url.Values + Headers http.Header + Hooks []Hook + JSON interface{} + Params url.Values + func NewArgs() *Args + func (a *Args) Reset() + type BasicAuth struct + Password string + Username string + type ContentType struct + Boundary string + Charset string + Type string + func (c ContentType) GetBoundary() string + func (c ContentType) GetCharset() string + func (c ContentType) String() string + type FileField struct + FieldName string + File io.Reader + FileName string + type Hook interface + AfterRequest func(req *http.Request, resp *http.Response, err error) (newResp *http.Response, newErr error) + BeforeRequest func(req *http.Request) (resp *http.Response, err error) + type IContentType interface + GetBoundary func() string + GetCharset func() string + String func() string + func NewContentType(contentType string) IContentType + type Request struct + func New() *Request + func (req *Request) AddFile(file FileField) *Request + func (req *Request) AddFormData(key, value string) *Request + func (req *Request) AddHook(hook Hook) *Request + func (req *Request) AddHooks(hooks ...Hook) *Request + func (req *Request) AddParam(key, value string) *Request + func (req *Request) Delete(url string) (*Response, error) + func (req *Request) Get(url string) (*Response, error) + func (req *Request) Head(url string) (*Response, error) + func (req *Request) Options(url string) (*Response, error) + func (req *Request) Patch(url string) (*Response, error) + func (req *Request) Post(url string) (*Response, error) + func (req *Request) Put(url string) (*Response, error) + func (req *Request) Reset() *Request + func (req *Request) SetBasicAuth(username, password string) *Request + func (req *Request) SetBody(body io.Reader) *Request + func (req *Request) SetContentType(contentType IContentType) *Request + func (req *Request) SetCookie(key, value string) *Request + func (req *Request) SetFormData(key, value string) *Request + func (req *Request) SetHeader(key, value string) *Request + func (req *Request) SetJSON(json interface{}) *Request + func (req *Request) SetParam(key, value string) *Request + func (req *Request) SetTimeout(t time.Duration) *Request + type Response struct + func Delete(url string, args *Args) (*Response, error) + func Get(url string, args *Args) (*Response, error) + func Head(url string, args *Args) (*Response, error) + func Options(url string, args *Args) (*Response, error) + func Patch(url string, args *Args) (*Response, error) + func Post(url string, args *Args) (*Response, error) + func Put(url string, args *Args) (*Response, error) + func Send(method, url string, args *Args) (*Response, error) + func (resp *Response) Content() (b []byte, err error) + func (resp *Response) JSON() (*simplejson.Json, error) + func (resp *Response) JSONUnmarshal(destPtr interface{}) error + func (resp *Response) OK() bool + func (resp *Response) Ok() bool + func (resp *Response) Reader() (reader io.ReadCloser, err error) + func (resp *Response) Reason() string + func (resp *Response) Text() (string, error) + func (resp *Response) URL() (*url.URL, error) + type RoundTripFunc func(req *http.Request) *http.Response + func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)