Documentation
¶
Index ¶
- Constants
- type Error
- type Handler
- type Request
- func (req *Request) DecodeParams(params any) error
- func (req *Request) Error(err error) *Response
- func (req *Request) InvalidMethod() *Response
- func (req *Request) InvalidParams(msg string) *Response
- func (req *Request) ReadFrom(r io.Reader) (int64, error)
- func (req *Request) Result(result any) *Response
- func (req *Request) String() string
- type Response
Constants ¶
View Source
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 // -32000 to -32599 Server error, Reserved for implementation-defined server-errors. CodeServerError = -32000 )
refer to JSON-RPC 2.0. https://www.jsonrpc.org/specification
View Source
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶ added in v0.1.0
type Request struct { Version string `json:"jsonrpc"` ID string `json:"id"` // only support string id Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` }
Request represents a JSON-RPC 2.0 request.
func (*Request) DecodeParams ¶ added in v0.1.0
DecodeParams decodes the request parameters into the given value.
func (*Request) Error ¶ added in v0.1.0
Error returns a response from the request with the given error.
func (*Request) InvalidMethod ¶ added in v0.1.0
InvalidMethod returns a invalid method response from the request.
func (*Request) InvalidParams ¶ added in v0.1.0
InvalidParams returns a invalid params response from the request with the given message.
func (*Request) ReadFrom ¶ added in v0.1.0
ReadFrom decodes the request from the given reader. ReadFrom implements io.ReaderFrom interface.
type Response ¶ added in v0.1.0
type Response struct { Version string `json:"jsonrpc"` ID string `json:"id"` Error *Error `json:"error,omitempty"` Result json.RawMessage `json:"result,omitempty"` }
Response represents a JSON-RPC response.
func (*Response) DecodeResult ¶ added in v0.1.0
DecodeResult decodes the result into the given value.
Click to show internal directories.
Click to hide internal directories.