-
Notifications
You must be signed in to change notification settings - Fork 1
/
encoder.json.go
122 lines (97 loc) · 2.69 KB
/
encoder.json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (c) 2019 Meng Huang ([email protected])
// This package is licensed under a MIT license that can be found in the LICENSE file.
package rpc
// JSONEncoder implements a header Encoder.
type JSONEncoder struct{}
// NewJSONEncoder returns a header Encoder.
func NewJSONEncoder() Encoder {
return &JSONEncoder{}
}
// NewRequest returns the instance of Request.
func (e *JSONEncoder) NewRequest() Request {
return NewJSONRequest()
}
// NewResponse returns the instance of Response.
func (e *JSONEncoder) NewResponse() Response {
return NewJSONResponse()
}
// NewCodec returns the instance of Codec.
func (e *JSONEncoder) NewCodec() Codec {
return NewJSONCodec()
}
// NewJSONCodec returns the instance of Codec.
func NewJSONCodec() Codec {
return &JSONCodec{}
}
// NewJSONRequest returns the instance of jsonRequest.
func NewJSONRequest() Request {
return &jsonRequest{}
}
// Reset resets the jsonRequest.
func (req *jsonRequest) Reset() {
*req = jsonRequest{}
}
// SetSeq sets the value of Seq.
func (req *jsonRequest) SetSeq(seq uint64) {
req.Seq = seq
}
// GetSeq returns the value of Seq.
func (req *jsonRequest) GetSeq() uint64 {
return req.Seq
}
// SetUpgrade sets the value of Upgrade.
func (req *jsonRequest) SetUpgrade(upgrade []byte) {
req.Upgrade = upgrade
}
// GetUpgrade returns the value of Upgrade.
func (req *jsonRequest) GetUpgrade() []byte {
return req.Upgrade
}
// SetServiceMethod sets the value of ServiceMethod.
func (req *jsonRequest) SetServiceMethod(serviceMethod string) {
req.ServiceMethod = serviceMethod
}
// GetServiceMethod returns the value of ServiceMethod.
func (req *jsonRequest) GetServiceMethod() string {
return req.ServiceMethod
}
// SetArgs sets the value of Args.
func (req *jsonRequest) SetArgs(args []byte) {
req.Args = args
}
// GetArgs returns the value of Args.
func (req *jsonRequest) GetArgs() []byte {
return req.Args
}
// NewJSONResponse returns the instance of jsonResponse.
func NewJSONResponse() Response {
return &jsonResponse{}
}
// Reset resets the jsonResponse.
func (res *jsonResponse) Reset() {
*res = jsonResponse{}
}
// SetSeq sets the value of Seq.
func (res *jsonResponse) SetSeq(seq uint64) {
res.Seq = seq
}
// GetSeq returns the value of Seq.
func (res *jsonResponse) GetSeq() uint64 {
return res.Seq
}
// SetError sets the value of Error.
func (res *jsonResponse) SetError(errorMsg string) {
res.Error = errorMsg
}
// GetError returns the value of Error.
func (res *jsonResponse) GetError() string {
return res.Error
}
// SetReply sets the value of Reply.
func (res *jsonResponse) SetReply(reply []byte) {
res.Reply = reply
}
// GetReply returns the value of Reply.
func (res *jsonResponse) GetReply() []byte {
return res.Reply
}