goProject/trunk/center/common/webserver/result.go
2025-01-23 16:12:49 +08:00

44 lines
925 B
Go

package webServer
import (
"encoding/json"
"fmt"
"goutil/logUtilPlus"
"net/http"
"strconv"
)
// responseResult
// @description: responseResult
// parameter:
// @w: w
// @responseObj: responseObj
// return:
func responseResult(w http.ResponseWriter, responseObj *ResponseObject) {
b, err := json.Marshal(responseObj)
if err != nil {
logUtilPlus.ErrorLog(fmt.Sprintf("序列化输出结果%v出错", responseObj))
return
}
w.Header().Add("Content-Length", strconv.Itoa(len(b)))
w.Write(b)
}
// responseResultByJson
// @description: responseResult
// parameter:
// @w: w
// @responseObj: responseObj
// return:
func responseResultByJson(w http.ResponseWriter, responseObj *ResponseObject) {
b, err := json.Marshal(responseObj)
if err != nil {
logUtilPlus.ErrorLog(fmt.Sprintf("序列化输出结果%v出错", responseObj))
return
}
w.Header().Add("Content-Length", strconv.Itoa(len(b)))
w.Write(b)
}