client

package module
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorPrefix = "JSON-RPC error: "

ErrorPrefix defines default prefix for error messages.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config defines config object for JSON-RPC Call.

func GetConfig

func GetConfig(url string) *Config

GetConfig returns default JSON-RPC Call config.

func GetSocketConfig

func GetSocketConfig(socket, endpoint string) *Config

GetSocketConfig returns default JSON-RPC Call config using Unix-Socket.

func (*Config) Call

func (c *Config) Call(method string, params json.RawMessage) (json.RawMessage, error)

Call wraps JSON-RPC client call.

func (*Config) DisableCompression

func (c *Config) DisableCompression(t bool)

DisableCompression disables compression inside HTTP request.

func (*Config) SetBasicAuth

func (c *Config) SetBasicAuth(username, password string)

SetBasicAuth adds Basic Authorization header to client requests.

func (*Config) SetHeader

func (c *Config) SetHeader(key, value string)

SetHeader sets custom request header.

func (*Config) SetTimeout

func (c *Config) SetTimeout(t int64)

SetTimeout sets request timeout time in seconds.

func (*Config) SkipSSLCertificateCheck

func (c *Config) SkipSSLCertificateCheck(t bool)

SkipSSLCertificateCheck disables server's certificate chain and host name check, INSECURE!.

type EmbeddedInternalError added in v1.0.14

type EmbeddedInternalError struct {
	Code     *int    `json:"code,omitempty"`
	ID       *string `json:"id,omitempty"`
	Protocol *string `json:"protocol,omitempty"`
}

EmbeddedInternalError represents embedded errors internal data.

type ErrorObject

type ErrorObject struct {
	// Code indicates the error type that occurred
	Code int `json:"code"`
	// Message provides a short description of the error
	Message string `json:"message"`
	// Data can contain additional information about the error
	Data json.RawMessage `json:"data,omitempty"`
}

ErrorObject represents a response error object.

func (*ErrorObject) Error added in v1.0.13

func (errObj *ErrorObject) Error() string

type InternalError added in v1.0.14

type InternalError struct {
	Prefix   string                 `json:"prefix"`
	Returned *EmbeddedInternalError `json:"returned,omitempty"`
	Expected *EmbeddedInternalError `json:"expected,omitempty"`
	Err      error                  `json:"err,omitempty"`
}

InternalError represents generic internal error object.

func NewInternalError added in v1.0.14

func NewInternalError(prefix string, err error) *InternalError

NewInternalError creates new generic internal error object.

func (*InternalError) Error added in v1.0.14

func (e *InternalError) Error() string

func (*InternalError) SetHTTPStatusCodes added in v1.0.14

func (e *InternalError) SetHTTPStatusCodes(returned, expected int) *InternalError

SetHTTPStatusCodes sets HTTP status codes in internal error object.

func (*InternalError) SetProtocolVersions added in v1.0.14

func (e *InternalError) SetProtocolVersions(returned, expected string) *InternalError

SetProtocolVersions sets JSON-RPC protocol versions in internal error object.

func (*InternalError) SetRPCIDs added in v1.0.14

func (e *InternalError) SetRPCIDs(returned, expected string) *InternalError

SetRPCIDs sets JSON-RPC IDs in internal error object.

type RequestObject

type RequestObject struct {
	// Jsonrpc specifies the version of the JSON-RPC protocol, equals to "2.0"
	Jsonrpc string `json:"jsonrpc"`
	// Method contains the name of the method to be invoked
	Method string `json:"method"`
	// Params holds Raw JSON parameter data to be used during the invocation of the method
	Params json.RawMessage `json:"params"`
	// ID is a unique identifier established by the client
	ID string `json:"id"`
}

RequestObject represents a request object.

type ResponseObject

type ResponseObject struct {
	// Jsonrpc specifies the version of the JSON-RPC protocol, equals to "2.0"
	Jsonrpc string `json:"jsonrpc"`
	// Error contains the error object if an error occurred while processing the request
	Error *ErrorObject `json:"error,omitempty"`
	// Result contains the result of the called method
	Result json.RawMessage `json:"result,omitempty"`
	// ID contains the client established request id or null
	ID string `json:"id"`
}

ResponseObject represents a response object.

Jump to

Keyboard shortcuts

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