xhttp

package
v1.5.59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2021 License: Apache-2.0 Imports: 15 Imported by: 21

Documentation

Index

Constants

View Source
const (
	GET                               = "GET"
	POST                              = "POST"
	PUT                               = "PUT"
	DELETE                            = "DELETE"
	PATCH                             = "PATCH"
	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

func FormatURLParam added in v1.5.47

func FormatURLParam(body map[string]interface{}) (urlParam string)

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) Delete

func (c *Client) Delete(url string) (client *Client)

func (*Client) EndBytes

func (c *Client) EndBytes() (res *http.Response, bs []byte, errs []error)

func (*Client) EndStruct

func (c *Client) EndStruct(v interface{}) (res *http.Response, errs []error)

func (*Client) Get

func (c *Client) Get(url string) (client *Client)

func (*Client) Patch added in v1.5.46

func (c *Client) Patch(url string) (client *Client)

func (*Client) Post

func (c *Client) Post(url string) (client *Client)

func (*Client) Put

func (c *Client) Put(url string) (client *Client)

func (*Client) SendBodyMap

func (c *Client) SendBodyMap(bm map[string]interface{}) (client *Client)

参数可直接传 gopay.BodyMap

func (*Client) SendMultipartBodyMap

func (c *Client) SendMultipartBodyMap(bm map[string]interface{}) (client *Client)

参数可直接传 gopay.BodyMap

func (*Client) SendString

func (c *Client) SendString(encodeStr string) (client *Client)

encodeStr: url.Values.Encode() or jsonBody

func (*Client) SendStruct

func (c *Client) SendStruct(v interface{}) (client *Client)

func (*Client) SetHost

func (c *Client) SetHost(host string) (client *Client)

func (*Client) SetTLSConfig

func (c *Client) SetTLSConfig(tlsCfg *tls.Config) (client *Client)

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration) (client *Client)

func (*Client) SetTransport added in v1.5.52

func (c *Client) SetTransport(transport *http.Transport) (client *Client)

func (*Client) Type

func (c *Client) Type(typeStr RequestType) (client *Client)

type RequestType

type RequestType string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL