-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructs.go
51 lines (41 loc) · 1.33 KB
/
structs.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
package jrpc2client
import (
"encoding/json"
"sync"
"time"
"github.com/sirupsen/logrus"
)
// ErrorCode type for error codes
type ErrorCode int
const (
userAgent = "RIFTBIT-JRPC2-CLIENT"
defaultContentType = "application/json"
)
// Client basic struct that contains all method to work with JSON-RPC 2.0 protocol
type Client struct {
disableHeaderNamesNormalizing bool
BaseURL string
clientTimeout time.Duration
customHeaders map[string]string
clientPool *sync.Pool
logger *logrus.Logger
}
// clientRequest represents a JSON-RPC request sent by a client.
type clientRequest struct {
// JSON-RPC protocol.
Version string `json:"jsonrpc"`
// A String containing the name of the method to be invoked.
Method string `json:"method"`
// Object to pass as request parameter to the method.
Params interface{} `json:"params"`
// The request id. This can be of any type. It is used to match the
// response with the request that it is replying to.
ID uint64 `json:"id"`
}
// clientResponse represents a JSON-RPC response returned to a client.
type clientResponse struct {
ID interface{} `json:"id"`
Version string `json:"jsonrpc"`
Result *json.RawMessage `json:"result"`
Error *json.RawMessage `json:"error"`
}