增加直接写结构体功能

This commit is contained in:
jau1jz
2019-03-11 14:54:51 +08:00
parent 44654e9bd0
commit 89559f0b71

View File

@@ -1,7 +1,10 @@
package sysservice
import (
"Server/common"
"encoding/json"
"fmt"
"github.com/duanhf2012/origin/sysmodule"
"io/ioutil"
"net/http"
"reflect"
@@ -141,3 +144,16 @@ func (slf *HttpServerService) SetHttps(certfile string, keyfile string) bool {
return true
}
//序列化后写入Respone
func (slf *HttpRespone) WriteRespne(v interface{}) error {
StrRet, retErr := json.Marshal(v)
if retErr == nil {
slf.Respone = []byte(`{"Code": 2,"Message":"service error"}`)
common.LogPrintf(sysmodule.LEVER_ERROR, "Json Marshal Error")
} else {
slf.Respone = StrRet
}
return retErr
}