initial import of sources
This commit is contained in:
33
request.go
Normal file
33
request.go
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
|
||||
*
|
||||
*/
|
||||
|
||||
package dsrpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Method string `json:"method" msgpack:"method"`
|
||||
Params any `json:"params,omitempty" msgpack:"params,omitempty"`
|
||||
Auth *Auth `json:"auth,omitempty" msgpack:"auth,omitempty"`
|
||||
}
|
||||
|
||||
func NewRequest() *Request {
|
||||
req := &Request{}
|
||||
req.Auth = &Auth{}
|
||||
return req
|
||||
}
|
||||
|
||||
func (this *Request) Pack() ([]byte, error) {
|
||||
rBytes, err := json.Marshal(this)
|
||||
return rBytes, err
|
||||
}
|
||||
|
||||
func (this *Request) JSON() []byte {
|
||||
jBytes, _ := json.Marshal(this)
|
||||
return jBytes
|
||||
}
|
||||
Reference in New Issue
Block a user