json2

package
v0.0.0-...-cb7d559 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "2.0"

Functions

func ReadRPCParams

func ReadRPCParams(params *json.RawMessage, args interface{}) error

Types

type ClientCodec

type ClientCodec struct {
}

func NewClientCodec

func NewClientCodec() *ClientCodec

func (*ClientCodec) DecodeClientResponse

func (c *ClientCodec) DecodeClientResponse(msg []byte, reply interface{}) error

DecodeClientResponse decodes the response body of a client request into the interface reply.

func (*ClientCodec) DecodeIdAndError

func (c *ClientCodec) DecodeIdAndError(msg []byte) (*uint32, error)

func (*ClientCodec) EncodeClientRequest

func (c *ClientCodec) EncodeClientRequest(call *rpc.Call) ([]byte, error)

EncodeClientRequest encodes parameters for a JSON-RPC client request.

type Codec

type Codec struct {
}

Codec creates a CodecRequest to process each request.

func NewCodec

func NewCodec() *Codec

NewCodec returns a new JSON Codec.

func (*Codec) NewRequest

func (c *Codec) NewRequest(topic string, payload []byte) (rpc.CodecRequest, error)

NewRequest returns a CodecRequest.

func (*Codec) SendNotification

func (c *Codec) SendNotification(client bus.Bus, topic string, payload ...interface{}) error

SendNotification sends a JSON-RPC notification

type CodecRequest

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

CodecRequest decodes and encodes a single request.

func (*CodecRequest) Method

func (c *CodecRequest) Method() (string, error)

Method returns the RPC method for the current request.

The method uses a dotted notation as in "Service.Method".

func (*CodecRequest) ReadRequest

func (c *CodecRequest) ReadRequest(args interface{}) error

ReadRequest fills the request object for the RPC method.

func (*CodecRequest) WriteError

func (c *CodecRequest) WriteError(client bus.Bus, err error)

func (*CodecRequest) WriteResponse

func (c *CodecRequest) WriteResponse(client bus.Bus, reply interface{})

WriteResponse encodes the response and writes it to the reply topic

type EmptyResponse

type EmptyResponse struct {
}

type Error

type Error struct {
	// A Number that indicates the error type that occurred.
	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 */
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int
const (
	E_PARSE       ErrorCode = -32700
	E_INVALID_REQ ErrorCode = -32600
	E_NO_METHOD   ErrorCode = -32601
	E_BAD_PARAMS  ErrorCode = -32602
	E_INTERNAL    ErrorCode = -32603
	E_SERVER      ErrorCode = -32000
)

Jump to

Keyboard shortcuts

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