jsonrpc2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(in []byte) []byte

func HttpHandler

func HttpHandler(rw http.ResponseWriter, req *http.Request)

func RegisterMethod

func RegisterMethod(method string, fn interface{})

func RunHttp

func RunHttp(cfg *HttpConfig)

func RunTcp

func RunTcp(cfg *TcpConfig)

Types

type Error

type Error struct {
	Code    int64  `json:"code"`
	Message string `json:"message"`
}

type HttpConfig

type HttpConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	Url  string `json:"url"`
}

type Request

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

type Response

type Response struct {
	Id      *json.RawMessage `json:"id"`
	JsonRPC string           `json:"jsonrpc"`
	Result  interface{}      `json:"result"`
	Error   interface{}      `json:"error"`
}

func Exec

func Exec(rec *Request) (resp *Response)

func MakeError

func MakeError(rec *Request, code int64, message string) *Response

type TcpConfig

type TcpConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

Jump to

Keyboard shortcuts

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