Documentation ¶
Index ¶
- Constants
- func NewMethod(name string, function interface{}) (*method, error)
- func Reply(w io.Writer, id Id, result interface{}) error
- func ReplyWithError(w io.Writer, id Id, code int64, message string) error
- func ReplyWithErrorData(w io.Writer, id Id, code int64, message string, data interface{}) error
- func ReplyWithErrorObject(w io.Writer, id Id, obj *Error) error
- type BatchRequest
- type BatchResponse
- type Error
- type Id
- type Message
- type Request
- type Response
- type Router
Constants ¶
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 )
JSONRPC 2.0 error codes.
const ProtocolVersion = "2.0"
Variables ¶
This section is empty.
Functions ¶
func ReplyWithErrorData ¶
Types ¶
type BatchRequest ¶
type BatchRequest []*Request
func (BatchRequest) MarshalEasyJSON ¶
func (v BatchRequest) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (BatchRequest) MarshalJSON ¶
func (v BatchRequest) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*BatchRequest) UnmarshalEasyJSON ¶
func (v *BatchRequest) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*BatchRequest) UnmarshalJSON ¶
func (v *BatchRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type BatchResponse ¶
type BatchResponse []*Response
func (BatchResponse) MarshalEasyJSON ¶
func (v BatchResponse) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (BatchResponse) MarshalJSON ¶
func (v BatchResponse) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*BatchResponse) UnmarshalEasyJSON ¶
func (v *BatchResponse) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*BatchResponse) UnmarshalJSON ¶
func (v *BatchResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type Error ¶
type Error struct { Code int64 `json:"code"` Message string `json:"message"` Data *json.RawMessage `json:"data,omitempty"` }
Error represents a JSON-RPC response error.
func ErrorWithData ¶
func (Error) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Error) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Error) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Error) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Message ¶
type Message struct { Request *Request Response *Response BatchRequest BatchRequest BatchResponse BatchResponse }
Message holds one of the unmarshaled messages (request or response).
func (*Message) UnmarshalJSON ¶
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params *json.RawMessage `json:"params,omitempty"` Id Id `json:"id,omitempty"` }
Request represents a JSON-RPC request or notification.
func (*Request) IsNotification ¶
func (Request) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Request) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Request) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Request) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Response ¶
type Response struct { JSONRPC string `json:"jsonrpc"` Result *json.RawMessage `json:"result,omitempty"` Error *Error `json:"error,omitempty"` Id Id `json:"id,omitempty"` }
Response represents a JSON-RPC response.
func (Response) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Response) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Response) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Response) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface