rpc

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package rpc provides functions to for rpc server call

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(address string, method string, id interface{}, params []interface{}) ([]byte, error)

Call sends RPC request to server

func Handle

func Handle(w http.ResponseWriter, r *http.Request)

this is the function that should be called in order to answer an rpc call should be registered like "http.HandleFunc("/", httpjsonrpc.Handle)"

func HandleFunc

func HandleFunc(pattern string, handler func([]interface{}) map[string]interface{})

a function to register functions to be called for specific rpc calls

func ResponsePack added in v1.15.0

func ResponsePack(errcode int64, result interface{}) map[string]interface{}

func ResponseSuccess added in v1.15.0

func ResponseSuccess(result interface{}) map[string]interface{}

func SetDefaultFunc

func SetDefaultFunc(def func(http.ResponseWriter, *http.Request))

a function to be called if the request is not a HTTP JSON RPC call

Types

type JReq added in v1.15.0

type JReq struct {
	JSONRPC string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	ID      interface{}   `json:"id"`
}

type ServeMux

type ServeMux struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

multiplexer that keeps track of every function to be called on specific rpc call

Jump to

Keyboard shortcuts

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