Documentation ¶
Index ¶
- Constants
- Variables
- func FormatURLParam(body map[string]any) (urlParam string)
- type BodyMap
- func (bm BodyMap) CheckEmptyError(keys ...string) error
- func (bm BodyMap) CheckNotAllEmptyError(keys ...string) error
- func (bm BodyMap) EncodeAliPaySignParams() string
- func (bm BodyMap) EncodeURLParams() string
- func (bm BodyMap) EncodeWeChatSignParams(apiKey string) string
- func (bm BodyMap) Get(key string) string
- func (bm BodyMap) GetInterface(key string) any
- func (bm BodyMap) GetString(key string) string
- func (bm BodyMap) JsonBody() (jb string)
- func (bm BodyMap) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)
- func (bm BodyMap) Remove(key string)
- func (bm BodyMap) Reset()
- func (bm BodyMap) Set(key string, value any) BodyMap
- func (bm BodyMap) SetBodyMap(key string, value func(b BodyMap)) BodyMap
- func (bm BodyMap) SetFormFile(key string, file *util.File) BodyMap
- func (bm BodyMap) Unmarshal(ptr any) (err error)
- func (bm *BodyMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
- type Client
- func (c *Client) Req(typeStr ...string) *Request
- func (c *Client) SetBodySize(sizeMB int) (client *Client)
- func (c *Client) SetTLSConfig(tlsCfg *tls.Config) (client *Client)
- func (c *Client) SetTimeout(timeout time.Duration) (client *Client)
- func (c *Client) SetTransport(transport *http.Transport) (client *Client)
- type DebugSwitch
- type Request
- func (r *Request) Delete(url string) *Request
- func (r *Request) EndBytes(ctx context.Context) (res *http.Response, bs []byte, err error)
- func (r *Request) EndStruct(ctx context.Context, v any) (res *http.Response, err error)
- func (r *Request) Get(url string) *Request
- func (r *Request) Patch(url string) *Request
- func (r *Request) Post(url string) *Request
- func (r *Request) Put(url string) *Request
- func (r *Request) SendBodyMap(bm map[string]any) (client *Request)
- func (r *Request) SendMultipartBodyMap(bm map[string]any) (client *Request)
- func (r *Request) SendString(encodeStr string) (client *Request)
- func (r *Request) SendStruct(v any) (c *Request)
Constants ¶
View Source
const ( NULL = "" SUCCESS = "SUCCESS" FAIL = "FAIL" OK = "OK" DebugOff = 0 DebugOn = 1 Version = "1.5.97" )
View Source
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" PATCH = "PATCH" ResTypeJSON = "json" ResTypeXML = "xml" TypeJSON = "json" TypeXML = "xml" TypeFormData = "form-data" TypeMultipartFormData = "multipart-form-data" )
Variables ¶
View Source
var ( MissWechatInitParamErr = errors.New("missing wechat init parameter") MissAlipayInitParamErr = errors.New("missing alipay init parameter") MissPayPalInitParamErr = errors.New("missing paypal init parameter") MissAppleInitParamErr = errors.New("missing apple init parameter") MissLakalaInitParamErr = errors.New("missing lakala init parameter") MissParamErr = errors.New("missing required parameter") MarshalErr = errors.New("marshal error") UnmarshalErr = errors.New("unmarshal error") SignatureErr = errors.New("signature error") VerifySignatureErr = errors.New("verify signature error") CertNotMatchErr = errors.New("cert not match error") GetSignDataErr = errors.New("get signature data error") )
Functions ¶
func FormatURLParam ¶
Types ¶
type BodyMap ¶
func (BodyMap) CheckEmptyError ¶
func (BodyMap) CheckNotAllEmptyError ¶
func (BodyMap) EncodeAliPaySignParams ¶
("bar=baz&foo=quux") sorted by key.
func (BodyMap) EncodeURLParams ¶
("bar=baz&foo=quux") sorted by key.
func (BodyMap) EncodeWeChatSignParams ¶
("bar=baz&foo=quux") sorted by key.
func (BodyMap) MarshalXML ¶
func (BodyMap) SetFormFile ¶
设置 FormFile
func (*BodyMap) UnmarshalXML ¶
type Client ¶
func NewClient ¶
func NewClient() (client *Client)
NewClient , default tls.Config{InsecureSkipVerify: true}
func (*Client) Req ¶
typeStr is request type and response type default is TypeJSON first param is request type second param is response data type
func (*Client) SetBodySize ¶
set body size (MB), default is 10MB
type DebugSwitch ¶
type DebugSwitch int8
type Request ¶
func (*Request) SendMultipartBodyMap ¶
func (*Request) SendString ¶
encodeStr: url.Values.Encode() or jsonBody
func (*Request) SendStruct ¶
Click to show internal directories.
Click to hide internal directories.