增加响应结果 -> receiver的解析
This commit is contained in:
parent
fdbec81b1c
commit
62d3c792ce
@ -40,9 +40,10 @@ type httpClient struct {
|
|||||||
// Date : 14:37 2023/2/14
|
// 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, receiver interface{}) ([]byte, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
response *httpclient.Response
|
response *httpclient.Response
|
||||||
c *httpclient.HttpClient
|
c *httpclient.HttpClient
|
||||||
|
responseData []byte
|
||||||
)
|
)
|
||||||
if nil == param {
|
if nil == param {
|
||||||
param = make(map[string]interface{})
|
param = make(map[string]interface{})
|
||||||
@ -64,7 +65,17 @@ func (hc *httpClient) Send(requestURL string, method string, header map[string]s
|
|||||||
return nil, fmt.Errorf("%v : %v", response.StatusCode, response.Status)
|
return nil, fmt.Errorf("%v : %v", response.StatusCode, response.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
return hc.getResponseBody(response)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// getResponseBody ...
|
// getResponseBody ...
|
||||||
|
Loading…
Reference in New Issue
Block a user