- weimob wsc api

This commit is contained in:
gazebo
2019-01-18 09:17:02 +08:00
parent 0d4bd09589
commit e06ec24013
6 changed files with 486 additions and 23 deletions

View File

@@ -58,6 +58,10 @@ const (
ErrLevelCodeIsNotOK = "JXC4_CODE_IS_NOT_OK"
)
const (
maxDataSizeDontOutput = 200 * 1024
)
// common api access error
var (
ErrAPIAccessFailed = errors.New("access API failed")
@@ -77,7 +81,11 @@ func init() {
}
func getClonedData(r *bytes.Buffer) string {
return string(r.Bytes())
retVal := string(r.Bytes())
if len(retVal) > maxDataSizeDontOutput {
return "request data is too large"
}
return retVal
}
func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.Request, config *APIConfig, handleResponse func(bodyMap map[string]interface{}) (string, error)) error {