Little refactoring

This commit is contained in:
2023-04-01 00:18:44 +02:00
parent 8dc753cd95
commit 8b3e722ea5
16 changed files with 354 additions and 562 deletions

View File

@@ -11,24 +11,31 @@ import (
encoder "github.com/vmihailenco/msgpack/v5"
)
type EmptyParams struct{}
func NewEmptyParams() *EmptyParams {
return &EmptyParams{}
}
type Request struct {
Method string `json:"method" msgpack:"method"`
Params any `json:"params,omitempty" msgpack:"params"`
Auth *Auth `json:"auth,omitempty" msgpack:"auth"`
}
func NewRequest() *Request {
func NewEmptyRequest() *Request {
req := &Request{}
req.Auth = &Auth{}
req.Params = NewEmptyParams()
return req
}
func (req *Request) Pack() ([]byte, error) {
rBytes, err := encoder.Marshal(req)
return rBytes, Err(err)
return rBytes, err
}
func (req *Request) JSON() []byte {
func (req *Request) ToJson() []byte {
jBytes, _ := json.Marshal(req)
return jBytes
}