Documentation
¶
Index ¶
Constants ¶
const ( ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 )
Standard error codes as defined in the JSON-RPC 2.0 specification.
const Version = "2.0"
Version represents the JSON-RPC protocol version supported by this package.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶ added in v0.0.2
HTTPHandler adapts a JSON-RPC Handler to a net/http.Handler.
Types ¶
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
Error represents a JSON-RPC 2.0 error object.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient issues JSON-RPC requests over HTTP.
func NewHTTPClient ¶
func NewHTTPClient(endpoint string, client *http.Client) *HTTPClient
NewHTTPClient constructs an HTTP JSON-RPC client targeting endpoint. If client is nil, http.DefaultClient is used.
func (*HTTPClient) Call ¶
Call sends the provided requests to the JSON-RPC endpoint. The payload is always encoded as a JSON array, even when only a single request is supplied. Responses are aligned with the order of the supplied requests, and notifications (requests without an id) yield nil entries in the returned slice.
type HandlerFunc ¶
HandlerFunc adapts a function to the Handler interface.
type RawClient ¶ added in v0.0.2
type RawClient struct {
// contains filtered or unexported fields
}
RawClient implements a JSON-RPC 2.0 client over an io.ReadWriteCloser transport.
func NewRawClient ¶ added in v0.0.2
func NewRawClient(rwc io.ReadWriteCloser) *RawClient
NewRawClient constructs a Client that communicates over rwc.
func (*RawClient) Call ¶ added in v0.0.2
Call sends the provided requests and returns their corresponding responses. The payload is encoded as a JSON array even when only a single request is supplied. Responses are aligned with the order of the supplied requests, and notifications (requests without an id) yield nil entries in the returned slice.
func (*RawClient) Close ¶ added in v0.0.2
Close terminates the underlying transport and releases resources.
func (*RawClient) CloseError ¶ added in v0.0.2
CloseError reports the error that caused the client to close, if any.
type RawServer ¶ added in v0.0.2
type RawServer struct {
// contains filtered or unexported fields
}
Server processes JSON-RPC requests over an io.ReadWriteCloser transport.
func NewRawServer ¶ added in v0.0.2
func NewRawServer(rwc io.ReadWriteCloser, handler Handler) *RawServer
NewRawServer constructs a Server that uses handler to process incoming requests.
func (*RawServer) Close ¶ added in v0.0.2
Close shuts down the server and closes the underlying transport.
func (*RawServer) CloseError ¶ added in v0.0.2
CloseError reports the error that closed the server, if any.