Documentation
¶
Index ¶
- type Client
- func (c *Client) Notify(method string, params map[string]any) error
- func (c *Client) Request(method string, params map[string]any) (map[string]any, error)
- func (c *Client) SetNotificationHandler(handler NotificationHandler)
- func (c *Client) SetRequestHandler(method string, handler RequestHandler)
- func (c *Client) Start()
- func (c *Client) Stop()
- type Error
- type Notification
- type NotificationHandler
- type Request
- type RequestHandler
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal JSON-RPC 2.0 client for stdio transport
func NewClient ¶
func NewClient(stdin io.WriteCloser, stdout io.ReadCloser) *Client
NewClient creates a new JSON-RPC client
func (*Client) SetNotificationHandler ¶
func (c *Client) SetNotificationHandler(handler NotificationHandler)
SetNotificationHandler sets the handler for incoming notifications
func (*Client) SetRequestHandler ¶
func (c *Client) SetRequestHandler(method string, handler RequestHandler)
SetRequestHandler registers a handler for incoming requests from the server
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data map[string]any `json:"data,omitempty"`
}
Error represents a JSON-RPC error response
type Notification ¶
type Notification struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params map[string]any `json:"params"`
}
Notification represents a JSON-RPC 2.0 notification
type NotificationHandler ¶
NotificationHandler handles incoming notifications
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID json.RawMessage `json:"id"`
Method string `json:"method"`
Params map[string]any `json:"params"`
}
Request represents a JSON-RPC 2.0 request
type RequestHandler ¶
RequestHandler handles incoming server requests and returns a result or error
Click to show internal directories.
Click to hide internal directories.