Documentation
¶
Overview ¶
Package jsonrpc provides a Clarify specific low-level RPC client. Clarify specific details include things like error data format, error codes and API Version headers.
Method names and result formats are not part of this package.
Index ¶
Constants ¶
const ( ErrBadRequest strError = "bad request" ErrBadResponse strError = "bad response" )
Client errors.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorData ¶
type ErrorData struct {
Trace string `json:"trace"`
Params map[string][]string `json:"params,omitempty"`
InvalidResources []InvalidResource `json:"invalidResources,omitempty"`
PartialResult json.RawMessage `json:"partialResult,omitempty"`
PathErrors json.RawMessage `json:"pathErrors,omitempty"`
}
ErrorData describes possible error data fields for the Clarify RPC server.
type HTTPError ¶
HTTPError described a transport-layer error that is returned when the RPC server can not be reached for some reason.
type HTTPHandler ¶
type HTTPHandler struct {
Client http.Client
URL string
RequestLogger func(request Request, trace string, latency time.Duration, err error)
}
HTTPHandler performs RPC requests via HTTP POST against the specified URL.
type InvalidResource ¶
type InvalidResource struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Message string `json:"message"`
InvalidFields map[string][]string `json:"invalidFields,omitempty"`
}
InvalidResource describes an invalid resource.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
ID int `json:"id"`
Params any `json:"params"`
// Transport layer parameters.
APIVersion string `json:"-"`
}
Request describe the structure of an RPC Request. The request should be initialized via NewRequest.
func NewRequest ¶
type ServerError ¶
type ServerError struct {
Code int `json:"code"`
Message string `json:"message"`
Data ErrorData `json:"data"`
}
ServerError describes the error format returned by the RPC server.
func (ServerError) Error ¶
func (err ServerError) Error() string