This commit is contained in:
aozhiwei 2023-08-12 20:31:39 +08:00
parent 0644461bc7
commit 7bffd9a638

View File

@ -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