Documentation ¶
Index ¶
- Variables
- type Client
- type HttpRequest
- func Delete(url string) *HttpRequest
- func Get(url string) *HttpRequest
- func Head(url string) *HttpRequest
- func NewRequest(method, rawurl string) *HttpRequest
- func Options(url string) *HttpRequest
- func Patch(url string, data interface{}) *HttpRequest
- func Post(url string, data interface{}, bodyType string) *HttpRequest
- func PostForm(u string, data url.Values) *HttpRequest
- func Put(url string, data interface{}, bodyType string) *HttpRequest
- func Request(method, url string) *HttpRequest
- func (r *HttpRequest) AddCookie(c *http.Cookie) *HttpRequest
- func (r *HttpRequest) AddHeader(key, value string) *HttpRequest
- func (r *HttpRequest) AddParam(key, value string) *HttpRequest
- func (r *HttpRequest) AllowRedirects(allow bool) *HttpRequest
- func (r *HttpRequest) Cookie(name string) (*http.Cookie, error)
- func (r *HttpRequest) Cookies() []*http.Cookie
- func (r *HttpRequest) DelHeader(key string) *HttpRequest
- func (r *HttpRequest) DelParam(key string) *HttpRequest
- func (r *HttpRequest) Header(key string) string
- func (r *HttpRequest) Param(key string) string
- func (r *HttpRequest) Path() string
- func (r *HttpRequest) Prepare() error
- func (r *HttpRequest) Query() url.Values
- func (r *HttpRequest) Send() (*HttpResponse, error)
- func (r *HttpRequest) SetBody(data interface{}, bodyType string) *HttpRequest
- func (r *HttpRequest) SetHeader(key, value string) *HttpRequest
- func (r *HttpRequest) SetParam(key, value string) *HttpRequest
- func (r *HttpRequest) SetRedirectMax(count int) *HttpRequest
- func (r *HttpRequest) Timeout(timeout time.Duration) *HttpRequest
- func (r *HttpRequest) Url() string
- type HttpResponse
- func (r *HttpResponse) Content() ([]byte, error)
- func (r *HttpResponse) Cookie(name string) *http.Cookie
- func (r *HttpResponse) Cookies() []*http.Cookie
- func (r *HttpResponse) Json(v interface{}) error
- func (r *HttpResponse) Location() (*url.URL, error)
- func (r *HttpResponse) Text() (string, error)
- func (r *HttpResponse) Xml(v interface{}) error
- type RedirectForbiddenError
- type Session
- func (s *Session) Cookie(key string, url *url.URL) (cookie *http.Cookie)
- func (s *Session) Cookies(url *url.URL) (cookies []*http.Cookie)
- func (s *Session) Delete(url string) *HttpRequest
- func (s *Session) Get(url string) *HttpRequest
- func (s *Session) Head(url string) *HttpRequest
- func (s *Session) Options(url string) *HttpRequest
- func (s *Session) Patch(url string, data interface{}) *HttpRequest
- func (s *Session) Post(url string, data interface{}, bodyType string) *HttpRequest
- func (s *Session) PostForm(u string, data url.Values) *HttpRequest
- func (s *Session) Put(url string, data interface{}, bodyType string) *HttpRequest
- func (s *Session) Request(method, url string) *HttpRequest
Constants ¶
This section is empty.
Variables ¶
var DefaultUserAgent = "Go Requests"
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) ForbidRedirects ¶
func (c *Client) ForbidRedirects()
func (*Client) SetTimeout ¶
type HttpRequest ¶
type HttpRequest struct { Client *Client Req *http.Request Params url.Values // contains filtered or unexported fields }
func Delete ¶
func Delete(url string) *HttpRequest
func Get ¶
func Get(url string) *HttpRequest
func Head ¶
func Head(url string) *HttpRequest
func NewRequest ¶
func NewRequest(method, rawurl string) *HttpRequest
func Options ¶
func Options(url string) *HttpRequest
func Patch ¶
func Patch(url string, data interface{}) *HttpRequest
func Post ¶
func Post(url string, data interface{}, bodyType string) *HttpRequest
func Put ¶
func Put(url string, data interface{}, bodyType string) *HttpRequest
func Request ¶
func Request(method, url string) *HttpRequest
func (*HttpRequest) AddCookie ¶
func (r *HttpRequest) AddCookie(c *http.Cookie) *HttpRequest
AddCookie does not attach more than one Cookie header field. That means all cookies, if any, are written into the same line, separated by semicolon.
func (*HttpRequest) AddHeader ¶
func (r *HttpRequest) AddHeader(key, value string) *HttpRequest
Add adds the key, value pair to the header. It appends to any existing values associated with key.
func (*HttpRequest) AddParam ¶
func (r *HttpRequest) AddParam(key, value string) *HttpRequest
func (*HttpRequest) AllowRedirects ¶
func (r *HttpRequest) AllowRedirects(allow bool) *HttpRequest
func (*HttpRequest) Cookie ¶
func (r *HttpRequest) Cookie(name string) (*http.Cookie, error)
Cookie returns the named cookie provided in the request or ErrNoCookie if not found.
func (*HttpRequest) Cookies ¶
func (r *HttpRequest) Cookies() []*http.Cookie
Cookies parses and returns the HTTP cookies sent with the request.
func (*HttpRequest) DelHeader ¶
func (r *HttpRequest) DelHeader(key string) *HttpRequest
Del deletes the values associated with key.
func (*HttpRequest) DelParam ¶
func (r *HttpRequest) DelParam(key string) *HttpRequest
func (*HttpRequest) Header ¶
func (r *HttpRequest) Header(key string) string
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "". To access multiple values of a key, access the map directly with CanonicalHeaderKey.
func (*HttpRequest) Param ¶
func (r *HttpRequest) Param(key string) string
Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.
func (*HttpRequest) Path ¶
func (r *HttpRequest) Path() string
func (*HttpRequest) Prepare ¶
func (r *HttpRequest) Prepare() error
func (*HttpRequest) Query ¶
func (r *HttpRequest) Query() url.Values
func (*HttpRequest) Send ¶
func (r *HttpRequest) Send() (*HttpResponse, error)
func (*HttpRequest) SetBody ¶
func (r *HttpRequest) SetBody(data interface{}, bodyType string) *HttpRequest
func (*HttpRequest) SetHeader ¶
func (r *HttpRequest) SetHeader(key, value string) *HttpRequest
Set sets the header entries associated with key to the single element value. It replaces any existing values associated with key.
func (*HttpRequest) SetParam ¶
func (r *HttpRequest) SetParam(key, value string) *HttpRequest
func (*HttpRequest) SetRedirectMax ¶
func (r *HttpRequest) SetRedirectMax(count int) *HttpRequest
func (*HttpRequest) Timeout ¶
func (r *HttpRequest) Timeout(timeout time.Duration) *HttpRequest
func (*HttpRequest) Url ¶
func (r *HttpRequest) Url() string
type HttpResponse ¶
type HttpResponse struct { Resp *http.Response StatusCode int RedirectForbidden bool // contains filtered or unexported fields }
func NewResponse ¶
func NewResponse(resp *http.Response) *HttpResponse
func (*HttpResponse) Content ¶
func (r *HttpResponse) Content() ([]byte, error)
func (*HttpResponse) Cookies ¶
func (r *HttpResponse) Cookies() []*http.Cookie
Cookies parses and returns the cookies set in the Set-Cookie headers.
func (*HttpResponse) Json ¶
func (r *HttpResponse) Json(v interface{}) error
func (*HttpResponse) Location ¶
func (r *HttpResponse) Location() (*url.URL, error)
Location returns the URL of the response's "Location" header, if present. Relative redirects are resolved relative to the Response's Request. ErrNoLocation is returned if no Location header is present.
func (*HttpResponse) Text ¶
func (r *HttpResponse) Text() (string, error)
func (*HttpResponse) Xml ¶
func (r *HttpResponse) Xml(v interface{}) error
type RedirectForbiddenError ¶
type RedirectForbiddenError struct { }
func NewRedirectForbiddenError ¶
func NewRedirectForbiddenError() *RedirectForbiddenError
func (*RedirectForbiddenError) Error ¶
func (e *RedirectForbiddenError) Error() string
type Session ¶
func NewSession ¶
func NewSession() *Session
func (*Session) Delete ¶
func (s *Session) Delete(url string) *HttpRequest
func (*Session) Get ¶
func (s *Session) Get(url string) *HttpRequest
func (*Session) Head ¶
func (s *Session) Head(url string) *HttpRequest
func (*Session) Options ¶
func (s *Session) Options(url string) *HttpRequest
func (*Session) Patch ¶
func (s *Session) Patch(url string, data interface{}) *HttpRequest
func (*Session) Post ¶
func (s *Session) Post(url string, data interface{}, bodyType string) *HttpRequest
func (*Session) Put ¶
func (s *Session) Put(url string, data interface{}, bodyType string) *HttpRequest
func (*Session) Request ¶
func (s *Session) Request(method, url string) *HttpRequest