This commit is contained in:
2023-02-11 07:52:40 +02:00
parent 5366bd7ff7
commit 59d850da3c
18 changed files with 1183 additions and 1208 deletions

View File

@@ -5,26 +5,25 @@
package dsrpc
import (
"encoding/json"
encoder "github.com/vmihailenco/msgpack/v5"
"encoding/json"
encoder "github.com/vmihailenco/msgpack/v5"
)
type Response struct {
Error string `json:"error" msgpack:"error"`
Result any `json:"result" msgpack:"result"`
Error string `json:"error" msgpack:"error"`
Result any `json:"result" msgpack:"result"`
}
func NewResponse() *Response {
return &Response{}
return &Response{}
}
func (resp *Response) JSON() []byte {
jBytes, _ := json.Marshal(resp)
return jBytes
jBytes, _ := json.Marshal(resp)
return jBytes
}
func (resp *Response) Pack() ([]byte, error) {
rBytes, err := encoder.Marshal(resp)
return rBytes, Err(err)
rBytes, err := encoder.Marshal(resp)
return rBytes, Err(err)
}