Skip to content

Commit

Permalink
feat: 新增设置httpClient的公有方法 (#378)
Browse files Browse the repository at this point in the history
Co-authored-by: wbl <[email protected]>
  • Loading branch information
wangbaolong and wbl authored Jun 15, 2024
1 parent 61ec1c5 commit ccd817a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions alipay/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,8 @@ func (a *Client) encryptBizContent(originData string) (string, error) {
}
return base64.StdEncoding.EncodeToString(encryptData), nil
}

// SetHttpClient 设置自定义的xhttp.Client
func (a *Client) SetHttpClient(client *xhttp.Client) {
a.hc = client
}
5 changes: 5 additions & 0 deletions allinpay/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ func (c *Client) doPost(ctx context.Context, path string, bm gopay.BodyMap) (bs
}
return bs, nil
}

// SetHttpClient 设置自定义的xhttp.Client
func (c *Client) SetHttpClient(client *xhttp.Client) {
c.hc = client
}
10 changes: 10 additions & 0 deletions wechat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func (w *Client) SetBodySize(sizeMB int) {
}
}

// SetHttpClient 设置自定义的xhttp.Client
func (w *Client) SetHttpClient(client *xhttp.Client) {
w.hc = client
}

// SetTLSHttpClient 设置自定义的xhttp.Client
func (w *Client) SetTLSHttpClient(client *xhttp.Client) {
w.tlsHc = client
}

// 向微信发送Post请求,对于本库未提供的微信API,可自行实现,通过此方法发送请求
// bm:请求参数的BodyMap
// path:接口地址去掉baseURL的path,例如:url为https://api.mch.weixin.qq.com/pay/micropay,只需传 pay/micropay
Expand Down
5 changes: 5 additions & 0 deletions wechat/v3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ func (c *ClientV3) SetBodySize(sizeMB int) {
c.hc.SetBodySize(sizeMB)
}
}

// SetHttpClient 设置自定义的xhttp.Client
func (c *ClientV3) SetHttpClient(client *xhttp.Client) {
c.hc = client
}

0 comments on commit ccd817a

Please sign in to comment.