jsonrpc

package
v0.0.0-...-10d6790 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessMessage

func ProcessMessage(msg []byte, debug bool, handler RpcHandler) (response []byte)

func WrapNotification

func WrapNotification(method string, msg interface{}) ([]byte, error)

func WrapResponse

func WrapResponse(id interface{}, msg interface{}) ([]byte, error)

Types

type FullHeader struct {
	Jsonrpc string           `json:"jsonrpc"`
	Id      *json.RawMessage `json:"id"`
	Result  *json.RawMessage `json:"result"`
	Params  *json.RawMessage `json:"params"`
	Error   *json.RawMessage `json:"error"`
	Method  string           `json:"method"`
}

type MessageHeader

type MessageHeader struct {
	Jsonrpc string           `json:"jsonrpc"`
	Method  string           `json:"method"`
	Params  *json.RawMessage `json:"params"`
}

type RequestHeader

type RequestHeader struct {
	Jsonrpc string           `json:"jsonrpc"`
	Id      *json.RawMessage `json:"id"`
	Method  string           `json:"method"`
	Params  *json.RawMessage `json:"params"`
}

type ResponseHeader

type ResponseHeader struct {
	Jsonrpc string           `json:"jsonrpc"`
	Id      *json.RawMessage `json:"id"`
	Result  *json.RawMessage `json:"result"`
	Error   *json.RawMessage `json:"error"`
}

type RpcErrCode

type RpcErrCode int
const (
	ErrParse      RpcErrCode = -32700
	ErrInvalidReq RpcErrCode = -32600
	ErrNoMethod   RpcErrCode = -32601
	ErrBadParams  RpcErrCode = -32602
	ErrInternal   RpcErrCode = -32603
)

type RpcHandler

type RpcHandler func(string, *json.RawMessage) (interface{}, RpcErrCode, error)

method name, json params -> error | rpc result

Jump to

Keyboard shortcuts

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