ing
This commit is contained in:
5
central/client/protocol/header.go
Normal file
5
central/client/protocol/header.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package protocol
|
||||
|
||||
type Header struct {
|
||||
Protocol string `json:"protocol"`
|
||||
}
|
||||
7
central/client/protocol/notification.go
Normal file
7
central/client/protocol/notification.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package protocol
|
||||
|
||||
type Notification struct {
|
||||
Header
|
||||
Method string `json:"method"`
|
||||
Params interface{} `json:"params,omitempty"`
|
||||
}
|
||||
19
central/client/protocol/protocol_error.go
Normal file
19
central/client/protocol/protocol_error.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package protocol
|
||||
|
||||
type ProtocolErrorCode int
|
||||
|
||||
const (
|
||||
ProtocolErrorCodeParse ProtocolErrorCode = -32700
|
||||
ProtocolErrorCodeInvalidRequest ProtocolErrorCode = -32600
|
||||
ProtocolErrorCodeNotFoundMethod ProtocolErrorCode = -32601
|
||||
ProtocolErrorCodeInvalidParams ProtocolErrorCode = -32602
|
||||
ProtocolErrorCodeInternal ProtocolErrorCode = -32603
|
||||
// -32000 ~ -32099
|
||||
ProtocolErrorCodeServer ProtocolErrorCode = -32000
|
||||
)
|
||||
|
||||
type ProtocolError struct {
|
||||
Code ProtocolErrorCode `json:"code"`
|
||||
Message *string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
6
central/client/protocol/request.go
Normal file
6
central/client/protocol/request.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package protocol
|
||||
|
||||
type Request struct {
|
||||
Notification
|
||||
ID uint64 `json:"id,omitempty"`
|
||||
}
|
||||
10
central/client/protocol/response.go
Normal file
10
central/client/protocol/response.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package protocol
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type Response struct {
|
||||
Header
|
||||
ID uint64 `json:"id"`
|
||||
Result *json.RawMessage `json:"result,omitempty"`
|
||||
Error *ProtocolError `json:"error,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user