1
This commit is contained in:
parent
0644461bc7
commit
7bffd9a638
21
sysutils.go
21
sysutils.go
@ -6,8 +6,9 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
//"io/ioutil"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func GetDaySeconds(seconds int64, timeZone int64) int64 {
|
||||
@ -54,26 +55,24 @@ func ResponseOk(w* http.ResponseWriter) {
|
||||
}
|
||||
|
||||
func ResponseErr(w* http.ResponseWriter, errCode int32, errMsg string) {
|
||||
/*respObj := NewMxoObject()
|
||||
respObj.SetXValue("errcode", NewXInt32(errCode))
|
||||
respObj.SetXValue("errmsg", NewXString(errMsg))
|
||||
Response(w, respObj.ToJsonStr())*/
|
||||
rspObj := map[string]interface{}{}
|
||||
rspObj["errcode"] = errCode
|
||||
rspObj["errmsg"] = errMsg
|
||||
jsonObj, _ := json.Marshal(rspObj)
|
||||
Response(w, string(jsonObj))
|
||||
}
|
||||
|
||||
func ResponseInt32Ok(w* http.ResponseWriter, key string, val int32) {
|
||||
(*w).Write([]byte(fmt.Sprintf(`{"errcode":0, "errmsg":"", "%s":%d}`, key, val)))
|
||||
}
|
||||
|
||||
/*
|
||||
func GetPostBody(r *http.Request) *XValue {
|
||||
func GetPostBody(r *http.Request) string {
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return NewXString("")
|
||||
return ""
|
||||
}
|
||||
v := NewXString(string(body))
|
||||
return v
|
||||
return string(body)
|
||||
}
|
||||
*/
|
||||
|
||||
func GetRequestRemoteAddr(r *http.Request) string {
|
||||
remoteAddr := r.RemoteAddr
|
||||
|
Loading…
x
Reference in New Issue
Block a user