This commit is contained in:
crusader 2018-04-06 19:43:55 +09:00
parent 0e6d2d1b4b
commit 70b50d14bb

View File

@ -2,6 +2,7 @@ package json
import ( import (
"encoding/json" "encoding/json"
"strings"
"git.loafle.net/commons/rpc-go/protocol" "git.loafle.net/commons/rpc-go/protocol"
cuej "git.loafle.net/commons/util-go/encoding/json" cuej "git.loafle.net/commons/util-go/encoding/json"
@ -130,9 +131,10 @@ func (src *ServerRequestCodec) NewResponse(reply interface{}, err error) ([]byte
func (src *ServerRequestCodec) NewResponseWithString(reply string, err error) ([]byte, error) { func (src *ServerRequestCodec) NewResponseWithString(reply string, err error) ([]byte, error) {
res := src.newServerResponse(nil, err) res := src.newServerResponse(nil, err)
if "" != reply { r := strings.TrimSpace(reply)
if "" != r {
var i interface{} var i interface{}
mErr := json.Unmarshal([]byte(reply), &i) mErr := json.Unmarshal([]byte(r), &i)
if nil != mErr { if nil != mErr {
return nil, mErr return nil, mErr
} }