Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConnectionIssue = errors.New("could not connect")
ErrConnectionIssue represents a connection problem.
var ErrInvalidNodeVersion = errors.New("invalid node version response")
ErrInvalidNodeVersion indicates that the /eth/v1/node/version API response format was not recognized.
var ErrMalformedHostname = errors.New("hostname must include port, separated by one colon, like example.com:3500")
ErrMalformedHostname is used to indicate if a host name's format is incorrect.
var ErrNotFound = errors.Wrap(ErrNotOK, "recv 404 NotFound response from API")
ErrNotFound specifically means that a '404 - NOT FOUND' response was received from the API.
var ErrNotOK = errors.New("did not receive 2xx response from API")
ErrNotOK is used to indicate when an HTTP request to the API failed with any non-2xx response code. More specific errors may be returned, but an error in reaction to a non-2xx response will always wrap ErrNotOK.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a wrapper object around the HTTP client.
func NewClient ¶
NewClient constructs a new client with the provided options (ex WithTimeout). `host` is the base host + port used to construct request urls. This value can be a URL string, or NewClient will assume an http endpoint if just `host:port` is used.
func (*Client) Get ¶
Get is a generic, opinionated GET function to reduce boilerplate amongst the getters in this package.
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt is a functional option for the Client type (http.Client wrapper)
func WithAuthenticationToken ¶
WithAuthenticationToken sets an oauth token to be used.
func WithRoundTripper ¶
func WithRoundTripper(t http.RoundTripper) ClientOpt
WithRoundTripper replaces the underlying HTTP's transport with a custom one.
func WithTimeout ¶
WithTimeout sets the .Timeout attribute of the wrapped http.Client.
type ReqOption ¶
ReqOption is a request functional option.
func WithAuthorizationToken ¶
WithAuthorizationToken is a request functional option that adds header for authorization token.
func WithSSZEncoding ¶
func WithSSZEncoding() ReqOption
WithSSZEncoding is a request functional option that adds SSZ encoding header.