Documentation ¶
Index ¶
- Constants
- func ContentMD5(b []byte) string
- func FileMD5(filename string) (string, int64)
- func HeaderEncode(h http.Header) string
- type Client
- func (c *Client) GetJSON(ctx context.Context, path string, query url.Values) (gjson.Result, error)
- func (c *Client) PostJSON(ctx context.Context, path string, params X) (gjson.Result, error)
- func (c *Client) PutStream(ctx context.Context, uploadURL string, reader io.ReadSeeker) error
- func (c *Client) PutStreamFromFile(ctx context.Context, uploadURL, filename string) error
- func (c *Client) Verify(header http.Header, body []byte) error
- type HTTPClient
- type HTTPOption
- type Option
- type ReqLog
- func (l *ReqLog) Do(ctx context.Context, log func(ctx context.Context, data map[string]string))
- func (l *ReqLog) Set(k, v string)
- func (l *ReqLog) SetReqBody(v string)
- func (l *ReqLog) SetReqHeader(h http.Header)
- func (l *ReqLog) SetRespBody(v string)
- func (l *ReqLog) SetRespHeader(h http.Header)
- func (l *ReqLog) SetStatusCode(code int)
- type SignOption
- type Signer
- type V
- type VEmptyMode
- type VEncOption
- type X
Constants ¶
View Source
const ( HeaderAccept = "Accept" HeaderContentType = "Content-Type" HeaderContentMD5 = "Content-MD5" HeaderTSignOpenAppID = "X-Tsign-Open-App-Id" HeaderTSignOpenAuthMode = "X-Tsign-Open-Auth-Mode" HeaderTSignOpenCaTimestamp = "X-Tsign-Open-Ca-Timestamp" HeaderTSignOpenCaSignature = "X-Tsign-Open-Ca-Signature" HeaderTSignOpenTimestamp = "X-Tsign-Open-TIMESTAMP" HeaderTSignOpenSignature = "X-Tsign-Open-SIGNATURE" )
View Source
const ( AcceptAll = "*/*" AuthModeSign = "Signature" ContentJSON = "application/json; charset=UTF-8" ContentStream = "application/octet-stream" )
Variables ¶
This section is empty.
Functions ¶
func HeaderEncode ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client E签宝客户端
func NewSandbox ¶
NewSandbox 返回E签宝「沙箱环境」客户端
func (*Client) PutStreamFromFile ¶
PutStreamFromFile 通过文件上传文件流
type HTTPClient ¶
type HTTPClient interface { // Do 发送HTTP请求 // 注意:应该使用Context设置请求超时时间 Do(ctx context.Context, method, reqURL string, body []byte, options ...HTTPOption) (*http.Response, error) }
HTTPClient HTTP客户端
func NewDefaultHTTPClient ¶
func NewDefaultHTTPClient() HTTPClient
NewDefaultHTTPClient 生成一个默认的HTTP客户端
func NewHTTPClient ¶
func NewHTTPClient(cli *http.Client) HTTPClient
NewHTTPClient 通过官方 `http.Client` 生成一个HTTP客户端
type HTTPOption ¶
type HTTPOption func(o *httpOptions)
HTTPOption HTTP请求选项
func HeaderToHttpOption ¶
func HeaderToHttpOption(h http.Header) []HTTPOption
func WithHTTPCookies ¶
func WithHTTPCookies(cookies ...*http.Cookie) HTTPOption
WithHTTPCookies 设置HTTP请求Cookie
func WithHTTPHeader ¶
func WithHTTPHeader(key string, vals ...string) HTTPOption
WithHTTPHeader 设置HTTP请求头
type ReqLog ¶
type ReqLog struct {
// contains filtered or unexported fields
}
ReqLog 请求日志
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer 签名器
func NewSigner ¶
func NewSigner(method, path string, options ...SignOption) *Signer
NewSigner 返回新的签名器
type V ¶
V 用于处理 k-v 需要格式化的场景,如:签名
type VEmptyMode ¶ added in v1.0.4
type VEmptyMode int
VEmptyMode 值为空时的Encode模式
const ( EmptyDefault VEmptyMode = iota // 默认:bar=baz&foo= EmptyIgnore // 忽略:bar=baz EmptyOnlyKey // 仅保留Key:bar=baz&foo )
type VEncOption ¶
type VEncOption func(o *vEncOptions)
VEncOption V Encode 选项
func WithEmptyMode ¶ added in v1.0.4
func WithEmptyMode(mode VEmptyMode) VEncOption
WithEmptyMode 设置值为空时的Encode模式
Click to show internal directories.
Click to hide internal directories.