- basic elm api added.

This commit is contained in:
gazebo
2018-06-13 17:10:41 +08:00
parent 47ecf4263d
commit 5f6865666a
4 changed files with 258 additions and 16 deletions

View File

@@ -4,6 +4,8 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"reflect"
"strconv"
"strings"
@@ -141,3 +143,17 @@ func GetCurTimestamp() int64 {
func GetAPIOperator() string {
return time.Now().Format("2006-01-02_15:04:05")
}
func HttpResponse2Json(response *http.Response) (map[string]interface{}, error) {
var jsonResult map[string]interface{}
bodyData, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
err = UnmarshalUseNumber(bodyData, &jsonResult)
if err != nil {
return nil, err
}
return jsonResult, nil
}