Esempio n. 1
0
func (c *serverCodec) WriteResponse(r *rpc.Response, body interface{}) error {
	var param proto.Message
	if body != nil {
		var ok bool
		if param, ok = body.(proto.Message); !ok {
			return fmt.Errorf("%T does not implement proto.Message", body)
		}
	}

	var rsp protorpcpb.Response
	rsp.Method = proto.String(r.ServiceMethod)
	rsp.Seq = proto.Uint64(r.Seq)
	rsp.Err = proto.String(r.Error)
	return writeMessage(c.rwc, &rsp, param)
}