jsonrpc: github.com/reviz0r/jsonrpc Index | Files

package jsonrpc

import "github.com/reviz0r/jsonrpc"


Package Files

constants.go context.go error.go error_code.go id.go method.go repo.go request.go response.go

func RequestID Uses

func RequestID(ctx context.Context) string

RequestID takes request id from context

type Error Uses

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

Error object

func ErrInternalError Uses

func ErrInternalError(data interface{}) *Error

ErrInternalError Internal JSON-RPC error.

func ErrInvalidParams Uses

func ErrInvalidParams(data interface{}) *Error

ErrInvalidParams Invalid method parameter(s).

func ErrInvalidRequest Uses

func ErrInvalidRequest(data interface{}) *Error

ErrInvalidRequest The JSON sent is not a valid Request object.

func ErrMethodNotFound Uses

func ErrMethodNotFound(data interface{}) *Error

ErrMethodNotFound The method does not exist / is not available.

func ErrParseError Uses

func ErrParseError(data interface{}) *Error

ErrParseError Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.

func (Error) Error Uses

func (e Error) Error() string

type Method Uses

type Method interface {
    Name() string
    Handle(ctx context.Context, params io.Reader, result io.Writer) error

Method jsonrpc

func MethodFunc Uses

func MethodFunc(name string, fn func(ctx context.Context, params io.Reader, result io.Writer) error) Method

MethodFunc wrap func to implement interface Method

type Repo Uses

type Repo struct {
    // contains filtered or unexported fields

Repo for storing methods

func New Uses

func New() *Repo

New repo

func (*Repo) RegisterMethod Uses

func (repo *Repo) RegisterMethod(method Method)

RegisterMethod registers method in repo

func (*Repo) ServeHTTP Uses

func (repo *Repo) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implement http.Handler for handling JSON-RPC requests

func (*Repo) UnregisterMethod Uses

func (repo *Repo) UnregisterMethod(name string)

UnregisterMethod removes method by name

Package jsonrpc imports 10 packages (graph). Updated 2019-08-11. Refresh now. Tools for package owners.