xhttp

package
v0.0.0-...-c24fb95 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

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

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

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

func (*Client) SetBodySize

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

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

type Request

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

func (*Request) Delete

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

func (*Request) EndBytes

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

func (*Request) EndStruct

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

func (*Request) Get

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

func (*Request) Patch

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

func (*Request) Post

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

func (*Request) Put

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

func (*Request) SendBodyMap

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

func (*Request) SendMultipartBodyMap

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

func (*Request) SendString

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

encodeStr: url.Values.Encode() or jsonBody

func (*Request) SendStruct

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