This commit is contained in:
crusader
2017-08-24 19:42:40 +09:00
parent 67de428f46
commit 37ce0a3668
8 changed files with 221 additions and 36 deletions

View 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"`
}

View 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
}

View 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"`
}