Documentation ¶
Index ¶
- func CheckResponse(resp *http.Response) error
- func SelectHeaderContentType(contentTypes []string) string
- func SortUrlValues(param url.Values) string
- func UnMarshalResponse(httpResp *http.Response, resp interface{}) error
- type APIError
- type APIResult
- type Client
- func (client *Client) ConstructFromData(ctx context.Context, apiName consts.ApiName, reqBody string) (err error, forData string)
- func (client *Client) GetApiPayServer() string
- func (client *Client) GetAppCode() string
- func (client *Client) Post(ctx context.Context, requestURL string, requestBody interface{}) (*APIResult, error)
- func (client *Client) Request(ctx context.Context, method, requestPath string, headerParams http.Header, ...) (result *APIResult, err error)
- func (client *Client) Sign(ctx context.Context, message string) (result *auth.SignatureResult, err error)
- type ClientOption
- type DialSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SelectHeaderContentType ¶
func SortUrlValues ¶
func UnMarshalResponse ¶
UnMarshalResponse 将回包组织成结构化数据
Types ¶
type APIError ¶
type APIError struct { StatusCode int // 应答报文的 HTTP 状态码 Header http.Header // 应答报文的 Header 信息 Body string // 应答报文的 Body 原文 Code string `json:"code"` // 应答报文的 Body 解析后错误信息,仅不符合预期/发生系统错误时存在 Message string `json:"message"` // 应答报文 Body 解析后的文字说明信息,仅不符合预期/发生系统错误时存在 Detail interface{} `json:"detail,omitempty"` // 应答报文 Body 解析后的详细信息,仅不符合预期/发生系统错误时存在 }
type APIResult ¶
type APIResult struct { // 本次请求所使用的 HTTPRequest Request *http.Request // 本次请求所获得到 HTTPResponse Response *http.Response }
APIResult 支付API请求结果
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(ctx context.Context, opts ...ClientOption) (client *Client, err error)
NewClient 初始化一个支付客户端
func (*Client) ConstructFromData ¶
func (*Client) GetApiPayServer ¶
func (*Client) GetAppCode ¶
func (*Client) Post ¶
func (client *Client) Post(ctx context.Context, requestURL string, requestBody interface{}) (*APIResult, error)
Post 向支付中心发送一个 HTTP Post请求
func (*Client) Request ¶
func (client *Client) Request( ctx context.Context, method, requestPath string, headerParams http.Header, queryParams url.Values, postBody interface{}, contentType string, ) (result *APIResult, err error)
Request 向 payCenter 发送请求
相比于 Get / Post / Put / Patch / Delete 方法, 本方法可以设置更多内容 特别地,如果需要为当前请求设置 Header, 可以使用本方法
type ClientOption ¶
type ClientOption interface {
Apply(*DialSettings) error
}
Click to show internal directories.
Click to hide internal directories.