jsonrpc

package
v0.0.0-...-24035bd Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "2.0"

Version is JSON-RPC version

Variables

View Source
var ErrNullResult = errors.New("result is null")

ErrNullResult is ...

Functions

This section is empty.

Types

type Error

type Error struct {
	// A Number that indicates the error type that occurred.
	// This MUST be an integer.
	Code ErrorCode `json:"code"` /* required */

	// A String providing a short description of the error.
	// The message SHOULD be limited to a concise single sentence.
	Message string `json:"message"` /* required */

	// A Primitive or Structured value that contains additional information about the error.
	Data interface{} `json:"data"` /* optional */
}

Error represents an JSON-RPC error object

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int

ErrorCode represents the error type that occurred.

const (
	ErrorCodeParse      ErrorCode = -32700
	ErrorCodeInvalidReq ErrorCode = -32600
	ErrorCodeNoMethod   ErrorCode = -32601
	ErrorCodeBadParams  ErrorCode = -32602
	ErrorCodeInternal   ErrorCode = -32603
	ErrorCodeServer     ErrorCode = -32000 /* -32000 to -32099 */
)

Error Code constants

type MethodHandler

type MethodHandler func(req *Request) (interface{}, error)

MethodHandler is

type Request

type Request struct {
	// A String specifying the version of the JSON-RPC protocol.
	// MUST be exactly "2.0".
	Version string `json:"jsonrpc"`

	// A String containing the name of the method to be invoked
	Method string `json:"method"`

	// A Structured value that holds the parameter values to be used during the
	// invocation of the method. This member MAY be omitted.
	Params *json.RawMessage `json:"params"`

	// An identifier established by the Client that MUST contain a String, Number,
	// or NULL value if included.
	// If it is not included it is assumed to be a notification.
	// The value SHOULD normally not be Null
	// and Numbers SHOULD NOT contain fractional parts
	ID *json.RawMessage `json:"id"`
}

Request represents a JSON-RPC request sent by a client.

type Server

type Server struct {
	MethodMap map[string]MethodHandler
}

Server is

func NewServer

func NewServer() *Server

NewServer return a new Jsonrpc server

func (*Server) Handler

func (s *Server) Handler(w http.ResponseWriter, r *http.Request)

Handler is ...

Jump to

Keyboard shortcuts

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