jsonrpc

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2022 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeParseError     = -32700
	CodeInvalidRequest = -32600
	CodeMethodNotFound = -32601
	CodeInvalidParams  = -32602
	CodeInternalError  = -32603
	CodeServerError    = -32000 // -32000 to -32099	Server error, Reserved for implementation-defined server-errors.
)
View Source
const (
	MIMEApplicationJSON            = "application/json"
	MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func (*Err) Error

func (err *Err) Error() string

type Req

type Req struct {
	Version string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

func DecodeReq

func DecodeReq(data []byte) (*Req, error)

func (*Req) DecodeParams

func (req *Req) DecodeParams(params interface{}) error

func (*Req) Error

func (req *Req) Error(err error) *Res

func (*Req) InvalidMethod

func (req *Req) InvalidMethod() *Res

func (*Req) InvalidParams

func (req *Req) InvalidParams(msg string) *Res

func (*Req) Result

func (req *Req) Result(result interface{}) *Res

func (*Req) String

func (req *Req) String() string

type Res

type Res struct {
	Version string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Error   *Err            `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
}

func DecodeRes

func DecodeRes(data []byte) (*Res, error)

func (*Res) DecodeResult

func (res *Res) DecodeResult(result interface{}) error

func (*Res) String

func (res *Res) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL