goProject/.svn/pristine/d1/d1f6e89e4dd7928626cfb64f2aa60c02f20b3377.svn-base
2025-01-06 16:21:36 +08:00

44 lines
925 B
Plaintext

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)
}