jsonrpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodTagToString

func MethodTagToString(mt MethodTag) string

MethodTagToString Преобразует тэг в строку

func RequestID

func RequestID(ctx context.Context) json.RawMessage

RequestID Получение id запроса из контекста

Types

type Error

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

Error object

func ErrInternalError

func ErrInternalError(data interface{}) *Error

ErrInternalError Internal JSON-RPC error.

func ErrInvalidParams

func ErrInvalidParams(data interface{}) *Error

ErrInvalidParams Invalid method parameter(s).

func ErrInvalidRequest

func ErrInvalidRequest(data interface{}) *Error

ErrInvalidRequest The JSON sent is not a valid Request object.

func ErrMethodNotFound

func ErrMethodNotFound(data interface{}) *Error

ErrMethodNotFound The method does not exist / is not available.

func ErrParseError

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

func (e Error) Error() string

type Method

type Method func(ctx context.Context, in io.Reader) (proto.Message, error)

Method Метод

type MethodTag

type MethodTag struct {
	Service, Method string
}

MethodTag Тэг метода

func MethodTagFromString

func MethodTagFromString(method string) MethodTag

MethodTagFromString Преобразует строку в тэг

type Repo

type Repo struct {
	Marshaler *jsonpb.Marshaler
	// contains filtered or unexported fields
}

Repo Репозиторий сервисов

func New

func New() *Repo

New Новый репозиторий

func (*Repo) RegisterService

func (repo *Repo) RegisterService(service Service)

RegisterService Зарегистрировать сервис

func (*Repo) ServeHTTP

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

ServeHTTP .

type Service

type Service interface {
	Methods() []string
	Exec(ctx context.Context, method string, in io.Reader) (proto.Message, error)
	JsonrpcService()
}

Service Сервис

Jump to

Keyboard shortcuts

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