- refactor platformapi.AccessPlatformAPIWithRetry

This commit is contained in:
gazebo
2019-01-12 14:04:37 +08:00
parent fc34194835
commit e124038aa2
11 changed files with 20 additions and 56 deletions

View File

@@ -159,11 +159,7 @@ func (a *API) AccessAPI(action string, params map[string]interface{}) (retVal *R
return request
},
a.config,
func(response *http.Response) (result string, err error) {
jsonResult1, err := utils.HTTPResponse2Json(response)
if err != nil {
return platformapi.ErrLevelGeneralFail, err
}
func(jsonResult1 map[string]interface{}) (result string, err error) {
resultError, _ := jsonResult1["error"].(map[string]interface{})
retVal = &ResponseResult{
ID: jsonResult1["id"].(string),
@@ -220,11 +216,7 @@ func (a *API) AcccessAPI2(baseURL string, params map[string]interface{}, method
return request
},
a.config,
func(response *http.Response) (result string, err error) {
jsonResult1, err := utils.HTTPResponse2Json(response)
if err != nil {
return platformapi.ErrLevelGeneralFail, err
}
func(jsonResult1 map[string]interface{}) (result string, err error) {
retVal = jsonResult1
return platformapi.ErrLevelSuccess, nil
})