This commit is contained in:
crusader
2017-09-21 17:38:05 +09:00
parent b1adb63ea8
commit 726b24f878
22 changed files with 568 additions and 156 deletions

View File

@@ -0,0 +1,5 @@
package protocol
type Header struct {
Protocol string `json:"protocol"`
}

View File

@@ -0,0 +1,7 @@
package protocol
type Notification struct {
Header
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}

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

View File

@@ -0,0 +1,6 @@
package protocol
type Request struct {
Notification
ID uint64 `json:"id,omitempty"`
}

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