xhttp

package
v1.5.97 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 16 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]any) (urlParam string)

Types

type Client

type Client struct {
	HttpClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (client *Client)

NewClient , default tls.Config{InsecureSkipVerify: true}

func (*Client) Req added in v1.5.97

func (c *Client) Req(typeStr ...RequestType) *Request

func (*Client) SetBodySize added in v1.5.82

func (c *Client) SetBodySize(sizeMB int) (client *Client)

set body size (MB), default is 10MB

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)

type Request added in v1.5.97

type Request struct {
	Header http.Header
	// contains filtered or unexported fields
}

func (*Request) Delete added in v1.5.97

func (r *Request) Delete(url string) *Request

func (*Request) EndBytes added in v1.5.97

func (r *Request) EndBytes(ctx context.Context) (res *http.Response, bs []byte, err error)

func (*Request) EndStruct added in v1.5.97

func (r *Request) EndStruct(ctx context.Context, v any) (res *http.Response, err error)

func (*Request) Get added in v1.5.97

func (r *Request) Get(url string) *Request

func (*Request) Patch added in v1.5.97

func (r *Request) Patch(url string) *Request

func (*Request) Post added in v1.5.97

func (r *Request) Post(url string) *Request

func (*Request) Put added in v1.5.97

func (r *Request) Put(url string) *Request

func (*Request) SendBodyMap added in v1.5.97

func (r *Request) SendBodyMap(bm map[string]any) (client *Request)

func (*Request) SendMultipartBodyMap added in v1.5.97

func (r *Request) SendMultipartBodyMap(bm map[string]any) (client *Request)

func (*Request) SendString added in v1.5.97

func (r *Request) SendString(encodeStr string) (client *Request)

encodeStr: url.Values.Encode() or jsonBody

func (*Request) SendStruct added in v1.5.97

func (r *Request) SendStruct(v any) (c *Request)

type RequestType

type RequestType string

Jump to

Keyboard shortcuts

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