jsonrpc

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 18 Imported by: 7

Documentation

Index

Constants

View Source
const (
	HeaderKeyIconOptions = "Icon-Options"
	IconOptionsDebug     = "debug"
	IconOptionsTimeout   = "timeout"
)
View Source
const Version = "2.0"

Variables

This section is empty.

Functions

func AttachDebug

func AttachDebug(je *Error, err error)

func ErrorHandler

func ErrorHandler(re *Error, c echo.Context)

Types

type Address

type Address string

func (Address) Address

func (addr Address) Address() module.Address

type Context

type Context struct {
	echo.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(c echo.Context) *Context

func (*Context) Chain

func (ctx *Context) Chain() (module.Chain, error)

func (*Context) GetTimeout

func (ctx *Context) GetTimeout(t time.Duration) time.Duration

func (*Context) IncludeDebug

func (ctx *Context) IncludeDebug() bool

type Error

type Error struct {
	Code    ErrorCode   `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func ErrInternal

func ErrInternal(message ...interface{}) *Error

func ErrInvalidParams

func ErrInvalidParams(message ...interface{}) *Error

func ErrInvalidRequest

func ErrInvalidRequest(message ...interface{}) *Error

func ErrMethodNotFound

func ErrMethodNotFound(message ...interface{}) *Error

func ErrParse

func ErrParse(message ...interface{}) *Error

func ErrScore

func ErrScore(err error, debug bool) *Error

func ErrScoreWithStatus

func ErrScoreWithStatus(s module.Status) *Error

func ErrServer

func ErrServer(message ...interface{}) *Error

func NewError

func NewError(code ErrorCode, err error, debug bool) *Error

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int
const (
	ErrorCodeJsonParse      ErrorCode = -32700
	ErrorCodeInvalidRequest ErrorCode = -32600
	ErrorCodeMethodNotFound ErrorCode = -32601
	ErrorCodeInvalidParams  ErrorCode = -32602
	ErrorCodeInternal       ErrorCode = -32603
	ErrorCodeServer         ErrorCode = -32000
	ErrorCodeSystem         ErrorCode = -31000
	ErrorCodeScore          ErrorCode = -30000
)
const (
	ErrorCodeTxPoolOverflow ErrorCode = -31001
	ErrorCodePending        ErrorCode = -31002
	ErrorCodeExecuting      ErrorCode = -31003
	ErrorCodeNotFound       ErrorCode = -31004
	ErrorLackOfResource     ErrorCode = -31005
	ErrorCodeTimeout        ErrorCode = -31006
	ErrorCodeSystemTimeout  ErrorCode = -31007
)

func (ErrorCode) Errorf

func (c ErrorCode) Errorf(f string, args ...interface{}) *Error

func (ErrorCode) New

func (c ErrorCode) New(msg string) *Error

func (ErrorCode) NewWithData

func (c ErrorCode) NewWithData(msg string, data interface{}) *Error

func (ErrorCode) Wrap

func (c ErrorCode) Wrap(err error, debug bool) *Error

type ErrorResponse

type ErrorResponse struct {
	Version string      `json:"jsonrpc"`
	Error   *Error      `json:"error"`
	ID      interface{} `json:"id"`
}

type Handler

type Handler func(ctx *Context, params *Params) (result interface{}, err error)

type HexBytes

type HexBytes string

func (HexBytes) Bytes

func (hs HexBytes) Bytes() []byte

type HexInt

type HexInt string

func (HexInt) ParseInt

func (i HexInt) ParseInt(bits int) (int64, error)

func (HexInt) Value

func (i HexInt) Value() int64

type IconOptions

type IconOptions map[string]string

func NewIconOptionsByHeader

func NewIconOptionsByHeader(h http.Header) IconOptions

func (IconOptions) Del

func (opts IconOptions) Del(key string)

func (IconOptions) Get

func (opts IconOptions) Get(key string) string

func (IconOptions) GetBool

func (opts IconOptions) GetBool(key string) (bool, error)

func (IconOptions) GetInt

func (opts IconOptions) GetInt(key string) (int64, error)

func (IconOptions) Set

func (opts IconOptions) Set(key, value string)

func (IconOptions) SetBool

func (opts IconOptions) SetBool(key string, value bool)

func (IconOptions) SetInt

func (opts IconOptions) SetInt(key string, v int64)

func (IconOptions) ToHeaderValue

func (opts IconOptions) ToHeaderValue() string

type MethodRepository

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

func NewMethodRepository

func NewMethodRepository() *MethodRepository

func (*MethodRepository) Handle

func (mr *MethodRepository) Handle(c echo.Context) (err error)

func (*MethodRepository) InvokeMethod

func (mr *MethodRepository) InvokeMethod(c echo.Context, r *Request) (interface{}, error)

func (*MethodRepository) RegisterMethod

func (mr *MethodRepository) RegisterMethod(method string, handler Handler)

func (*MethodRepository) TakeMethod

func (mr *MethodRepository) TakeMethod(r *Request) (Handler, error)

type Params

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

func (*Params) Convert

func (p *Params) Convert(v interface{}) error

func (*Params) IsEmpty

func (p *Params) IsEmpty() bool

func (*Params) RawMessage

func (p *Params) RawMessage() []byte

type Request

type Request struct {
	Version string          `json:"jsonrpc" validate:"required,version"`
	Method  string          `json:"method" validate:"required"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      interface{}     `json:"id"`
}

type Response

type Response struct {
	Version string      `json:"jsonrpc"`
	Result  interface{} `json:"result"`
	Error   *Error      `json:"error,omitempty"`
	ID      interface{} `json:"id"`
}

type Validator

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

func NewValidator

func NewValidator() *Validator

func (*Validator) RegisterAlias

func (v *Validator) RegisterAlias(alias string, tags string)

func (*Validator) RegisterStructValidation

func (v *Validator) RegisterStructValidation(fn validator.StructLevelFunc, types ...interface{})

func (*Validator) RegisterValidation

func (v *Validator) RegisterValidation(tag string, fn validator.Func)

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Jump to

Keyboard shortcuts

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