ing
This commit is contained in:
19
clients/protocol/server_error.go
Normal file
19
clients/protocol/server_error.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package protocol
|
||||
|
||||
type ServerErrorCode int
|
||||
|
||||
const (
|
||||
ServerErrorCodeParse ServerErrorCode = -32700
|
||||
ServerErrorCodeInvalidRequest ServerErrorCode = -32600
|
||||
ServerErrorCodeNotFoundMethod ServerErrorCode = -32601
|
||||
ServerErrorCodeInvalidParams ServerErrorCode = -32602
|
||||
ServerErrorCodeInternal ServerErrorCode = -32603
|
||||
// -32000 ~ -32099
|
||||
ServerErrorCodeServer ServerErrorCode = -32000
|
||||
)
|
||||
|
||||
type ServerError struct {
|
||||
Code ServerErrorCode `json:"code"`
|
||||
Message interface{} `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
17
clients/protocol/server_request.go
Normal file
17
clients/protocol/server_request.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type ServerRequest struct {
|
||||
Method string `json:"method"`
|
||||
Params *json.RawMessage `json:"params"`
|
||||
Id *json.RawMessage `json:"id"`
|
||||
}
|
||||
|
||||
func (r *ServerRequest) reset() {
|
||||
r.Method = ""
|
||||
r.Params = nil
|
||||
r.Id = nil
|
||||
}
|
||||
11
clients/protocol/server_response.go
Normal file
11
clients/protocol/server_response.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type ServerResponse struct {
|
||||
Id *json.RawMessage `json:"id"`
|
||||
Result interface{} `json:"result"`
|
||||
Error interface{} `json:"error"`
|
||||
}
|
||||
Reference in New Issue
Block a user