jsonrpc

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseError     = -32700
	InvalidRequest = -32600
	MethodNotFound = -32601
	InvalidParams  = -32602
	InternalError  = -32603
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

func NewNotification

func NewNotification(method string, params interface{}) (*Notification, error)

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *ResponseError  `json:"error,omitempty"`
}

func NewErrorResponse

func NewErrorResponse(id json.RawMessage, code int, message string) *Response

func NewResponse

func NewResponse(id json.RawMessage, result interface{}) (*Response, error)

type ResponseError

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

func (*ResponseError) Error

func (e *ResponseError) Error() string

type Transport

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

func NewTransport

func NewTransport(in io.Reader, out io.Writer) *Transport

func (*Transport) ReadMessage

func (t *Transport) ReadMessage() (json.RawMessage, error)

func (*Transport) WriteMessage

func (t *Transport) WriteMessage(data []byte) error

Jump to

Keyboard shortcuts

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