jsonrpc

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMethod

func RegisterMethod(method string, handlerFunc HandlerFunc, paramsType interface{})

RegisterMethod register a method to the default handler.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is a handler handling JSON-RPC protocol.

func NewHandler

func NewHandler() *Handler

NewHandler creates a new JSONRPCHandler.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request)

Handle implements jsonrpc2.Handler.

func (*Handler) RegisterMethod

func (h *Handler) RegisterMethod(method string, handlerFunc HandlerFunc, paramsType interface{})

RegisterMethod register a method.

type HandlerFunc

type HandlerFunc func(context.Context, *jsonrpc2.Conn, *jsonrpc2.Request) (interface{}, error)

HandlerFunc is a function adapter to Handler.

type Validator

type Validator interface {
	Validate() error
}

Validator is designed for params checking.

type WebsocketServer

type WebsocketServer struct {
	http.Server
	RPCHandler jsonrpc2.Handler
}

WebsocketServer is a websocket server providing JSON-RPC API service.

func (*WebsocketServer) Serve

func (ws *WebsocketServer) Serve() error

Serve accepts incoming connections and serve each.

func (*WebsocketServer) Stop

func (ws *WebsocketServer) Stop()

Stop stops the server and returns a channel indicating server is stopped.

Jump to

Keyboard shortcuts

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