diff --git a/httpclient.go b/httpclient.go index 6eaf929..bb8a347 100644 --- a/httpclient.go +++ b/httpclient.go @@ -40,9 +40,10 @@ type httpClient struct { // 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) { var ( - err error - response *httpclient.Response - c *httpclient.HttpClient + err error + response *httpclient.Response + c *httpclient.HttpClient + responseData []byte ) if nil == param { 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 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 ...