Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Delete(url string) (client *Client)
- func (c *Client) EndBytes() (res *http.Response, bs []byte, errs []error)
- func (c *Client) EndStruct(v interface{}) (res *http.Response, errs []error)
- func (c *Client) Get(url string) (client *Client)
- func (c *Client) Post(url string) (client *Client)
- func (c *Client) Put(url string) (client *Client)
- func (c *Client) SendBodyMap(bm map[string]interface{}) (client *Client)
- func (c *Client) SendMultipartBodyMap(bm map[string]interface{}) (client *Client)
- func (c *Client) SendString(encodeStr string) (client *Client)
- func (c *Client) SendStruct(v interface{}) (client *Client)
- func (c *Client) SetHost(host string) (client *Client)
- func (c *Client) SetTLSConfig(tlsCfg *tls.Config) (client *Client)
- func (c *Client) SetTimeout(timeout time.Duration) (client *Client)
- func (c *Client) Type(typeStr RequestType) (client *Client)
- type RequestType
Constants ¶
View Source
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" TypeJSON RequestType = "json" TypeXML RequestType = "xml" TypeUrlencoded RequestType = "urlencoded" TypeForm RequestType = "form" TypeFormData RequestType = "form-data" TypeMultipartFormData RequestType = "multipart-form-data" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // A Client is an HTTP client. HttpClient *http.Client // Transport specifies the mechanism by which individual // HTTP requests are made. // If nil, DefaultTransport is used. Transport *http.Transport // Header contains the request header fields either received // by the server or to be sent by the client. // // If a server received a request with header lines, // // Host: example.com // accept-encoding: gzip, deflate // Accept-Language: en-us // fOO: Bar // foo: two // // then // // Header = map[string][]string{ // "Accept-Encoding": {"gzip, deflate"}, // "Accept-Language": {"en-us"}, // "Foo": {"Bar", "two"}, // } // // For incoming requests, the Host header is promoted to the // Request.Host field and removed from the Header map. // // HTTP defines that header names are case-insensitive. The // request parser implements this by using CanonicalHeaderKey, // making the first character and any characters following a // hyphen uppercase and the rest lowercase. // // For client requests, certain headers such as Content-Length // and Connection are automatically written when needed and // values in Header may be ignored. See the documentation // for the Request.Write method. Header http.Header // Timeout specifies a time limit for requests made by this // Client. The timeout includes connection time, any // redirects, and reading the response body. The timer remains // running after Get, Head, Post, or Do return and will // interrupt reading of the Response.Body. // // A Timeout of zero means no timeout. // // The Client cancels requests to the underlying Transport // as if the Request's Context ended. // // For compatibility, the Client will also use the deprecated // CancelRequest method on Transport if found. New // RoundTripper implementations should use the Request's Context // for cancellation instead of implementing CancelRequest. Timeout time.Duration // For server requests, Host specifies the host on which the // URL is sought. For HTTP/1 (per RFC 7230, section 5.4), this // is either the value of the "Host" header or the host name // given in the URL itself. For HTTP/2, it is the value of the // ":authority" pseudo-header field. // It may be of the form "host:port". For international domain // names, Host may be in Punycode or Unicode form. Use // golang.org/x/net/idna to convert it to either format if // needed. // To prevent DNS rebinding attacks, server Handlers should // validate that the Host header has a value for which the // Handler considers itself authoritative. The included // ServeMux supports patterns registered to particular host // names and thus protects its registered Handlers. // // For client requests, Host optionally overrides the Host // header to send. If empty, the Request.Write method uses // the value of URL.Host. Host may contain an international // domain name. Host string FormString string // ContentType, now only support json, form, form-data, urlencoded, xml ContentType string Errors []error // contains filtered or unexported fields }
func NewClient ¶
func NewClient() (client *Client)
NewClient , default tls.Config{InsecureSkipVerify: true}
func (*Client) SendBodyMap ¶
参数可直接传 gopay.BodyMap
func (*Client) SendMultipartBodyMap ¶
参数可直接传 gopay.BodyMap
func (*Client) SendString ¶
encodeStr: url.Values.Encode() or jsonBody
func (*Client) SendStruct ¶
func (*Client) Type ¶
func (c *Client) Type(typeStr RequestType) (client *Client)
type RequestType ¶
type RequestType string
Click to show internal directories.
Click to hide internal directories.