Documentation
¶
Index ¶
- type Client
- func (c *Client) DELETE(url string) (*http.Response, error)
- func (c *Client) Do(method, url string, data []byte) (*http.Response, error)
- func (c *Client) GET(url string) (*http.Response, error)
- func (c *Client) PATCH(url string) (*http.Response, error)
- func (c *Client) POST(url string) (*http.Response, error)
- func (c *Client) PUT(url string) (*http.Response, error)
- func (c *Client) PostFile(url, fileName, field string, fileContent []byte) (*http.Response, error)
- func (c *Client) PostRaw(url string, data []byte) (*http.Response, error)
- func (c *Client) SetContentType(contentType ContentType) *Client
- func (c *Client) SetCookie(cookie *http.Cookie) *Client
- func (c *Client) SetHeader(h map[string]string) *Client
- func (c *Client) SetHeaderFace(h map[string]string) *Client
- func (c *Client) SetHost(host string) *Client
- func (c *Client) SetParams(p map[string][]string) *Client
- type Config
- type ContentType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client http request client provides more useful methods for requesting one url than http.Request.
func NewClientWithProxy ¶
NewClientWithProxy returns http Client with custom proxy property. example:
func(req *http.Request) (*url.URL, error) {
u, _ := url.ParseRequestURI("http://127.0.0.1:8118")
return u, nil
}
func NewTimeoutClient ¶
NewTimeoutClient returns http Client with custom timeout.
func (*Client) SetContentType ¶
func (c *Client) SetContentType(contentType ContentType) *Client
SetContentType sets "Content-Type" header field.
func (*Client) SetHeader ¶
SetHeader sets http header. Keep the first letter of param is capitalized.
func (*Client) SetHeaderFace ¶
SetHeaderFace sets http header. Keep param is original words, don't change the case of letters. https://golang.org/pkg/net/http/#CanonicalHeaderKey
type Config ¶
type Config struct {
Timeout time.Duration // Time out
DisableKeepAlives bool // Disable keep alives
InsecureSkipVerify bool // Skip secure verify
Encode bool // Encode URL for GET method
IsEncodeForGo bool // To encode URL by golang lib
Charset string // Charset (default UTF-8)
Certificates []tls.Certificate // SSL certificate
Proxy func(*http.Request) (*url.URL, error)
}
Config is used to override the default http client settings.
type ContentType ¶
type ContentType string
ContentType is used to indicate the media type of the resource.
const ( Raw ContentType = "application/raw" // Raw MIME type XML ContentType = "application/xml" // XML MIME type JSON ContentType = "application/json" // JSON MIME type TEXT ContentType = "application/text" // Text MIME type HTML ContentType = "application/html" // HTML MIME type )