- basic elm api added.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user