增加响应结果 -> receiver的解析

This commit is contained in:
白茶清欢 2023-02-14 15:32:45 +08:00
parent 62d3c792ce
commit e5ff8dcdf3

View File

@ -38,12 +38,11 @@ type httpClient struct {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:37 2023/2/14
func (hc *httpClient) Send(requestURL string, method string, header map[string]string, param map[string]interface{}, options httpclient.Map, receiver interface{}) ([]byte, error) {
func (hc *httpClient) Send(requestURL string, method string, header map[string]string, param map[string]interface{}, options httpclient.Map) ([]byte, error) {
var (
err error
response *httpclient.Response
c *httpclient.HttpClient
responseData []byte
err error
response *httpclient.Response
c *httpclient.HttpClient
)
if nil == param {
param = make(map[string]interface{})
@ -65,17 +64,7 @@ func (hc *httpClient) Send(requestURL string, method string, header map[string]s
return nil, fmt.Errorf("%v : %v", response.StatusCode, response.Status)
}
if responseData, err = hc.getResponseBody(response); nil != err {
return nil, err
}
if nil == receiver {
return responseData, nil
}
if err = json.Unmarshal(responseData, receiver); nil != err {
return responseData, err
}
return responseData, err
return hc.getResponseBody(response)
}
// getResponseBody ...