1
This commit is contained in:
@@ -68,7 +68,7 @@ func (a *API) sign(uid, timestamp string, param string) (sign string) {
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(aa)))
|
||||
}
|
||||
|
||||
func (a *API) HttpPostJson(url string, data interface{}) *TIResponse {
|
||||
func (a *API) HttpPostJson(url string, data interface{}) (*TIResponse, error) {
|
||||
//序列化参数
|
||||
b, err := json.Marshal(&data)
|
||||
if err != nil {
|
||||
@@ -77,7 +77,7 @@ func (a *API) HttpPostJson(url string, data interface{}) *TIResponse {
|
||||
result := TIResponse{
|
||||
HttpStatusCode: 500,
|
||||
}
|
||||
return &result
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
fullUrl := utils.GenerateGetURL(BaseUrl, url, nil)
|
||||
@@ -97,14 +97,12 @@ func (a *API) HttpPostJson(url string, data interface{}) *TIResponse {
|
||||
resp, err := client.Do(request)
|
||||
//resp, err := http.Post(utils.GenerateGetURL(BaseUrl, url, nil), "application/json;charset=UTF-8", bytes.NewBuffer(b))
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
glo
|
||||
var msg = fmt.Sprintf("post json error:%+v", err)
|
||||
fmt.Println(msg)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := TIResponse{
|
||||
@@ -116,11 +114,10 @@ func (a *API) HttpPostJson(url string, data interface{}) *TIResponse {
|
||||
if err == nil {
|
||||
result.BaseRes = &content
|
||||
} else {
|
||||
var msg = fmt.Sprintf("unmarshal body failed, error:%+v", err)
|
||||
fmt.Println(msg)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func StrRepeat(str string, repeatTimes int) string {
|
||||
|
||||
Reference in New Issue
Block a user