initial import of sources
This commit is contained in:
31
response.go
Normal file
31
response.go
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
|
||||
*
|
||||
*/
|
||||
|
||||
package dsrpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
|
||||
type Response struct {
|
||||
Error string `json:"error,omitempty" msgpack:"error,omitempty"`
|
||||
Result any `json:"result,omitemty" msgpack:"result,omitemty"`
|
||||
}
|
||||
|
||||
func NewResponse() *Response {
|
||||
return &Response{}
|
||||
}
|
||||
|
||||
func (this *Response) JSON() []byte {
|
||||
jBytes, _ := json.Marshal(this)
|
||||
return jBytes
|
||||
}
|
||||
|
||||
func (this *Response) Pack() ([]byte, error) {
|
||||
rBytes, err := json.Marshal(this)
|
||||
return rBytes, err
|
||||
}
|
||||
Reference in New Issue
Block a user