clients

package
v0.0.0-...-f003305 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnableToDecode unable to decode body
	ErrUnableToDecode = "unable to decode response"
	// ErrProtocolError the error was within the data that went into the endpoint
	ErrProtocolError = "protocol error"
	// ErrUnableToEscapeURL the url could nto be escaped
	ErrUnableToEscapeURL = "unable to escape url"
	// ErrInvalidHost the host was invalid
	ErrInvalidHost = "invalid host"
	// ErrMalformedRequest the request was malformed
	ErrMalformedRequest = "malformed request"
	// ErrUnableToEncodeBody body could not be decoded
	ErrUnableToEncodeBody = "unable to encode body"
)

Functions

func NewHTTPError

func NewHTTPError(err error, path, message string, status int, v interface{}) error

NewHTTPError creates a new errors.ErrorBundle with an HTTPState wrapping the status, path and v.

func RedactSensitiveHeaders

func RedactSensitiveHeaders(corpus []byte) []byte

RedactSensitiveHeaders from http request dumps

Types

type BitflyerError

type BitflyerError struct {
	Message        string   `json:"message"`
	ErrorIDs       []string `json:"errors"`
	Label          string   `json:"label"`
	Status         int      `json:"status"` // might be signed
	HTTPStatusCode int      `json:"-"`
}

BitflyerError holds error info directly from bitflyer

func (*BitflyerError) Error

func (bfe *BitflyerError) Error() string

Error returns the error string

type HTTPState

type HTTPState struct {
	Status int
	Path   string
	Body   interface{}
}

HTTPState captures the state of the response to be read by lower fns in the stack

type QueryStringBody

type QueryStringBody interface {
	// GenerateQueryString - function to generate the query string
	GenerateQueryString() (url.Values, error)
}

QueryStringBody - a type to generate the query string from a request "body" for the client

type RespErrData

type RespErrData struct {
	ResponseHeaders interface{}
	Body            interface{}
}

RespErrData - error data for http response

type SimpleHTTPClient

type SimpleHTTPClient struct {
	BaseURL   *url.URL
	AuthToken string
	// contains filtered or unexported fields
}

SimpleHTTPClient wraps http.Client for making simple token authorized requests

func New

func New(serverURL string, authToken string) (*SimpleHTTPClient, error)

New returns a new SimpleHTTPClient

func NewWithHTTPClient

func NewWithHTTPClient(serverURL string, authToken string, client *http.Client) (*SimpleHTTPClient, error)

NewWithHTTPClient returns a new SimpleHTTPClient, using the provided http.Client

func NewWithProxy

func NewWithProxy(name string, serverURL string, authToken string, proxyURL string) (*SimpleHTTPClient, error)

NewWithProxy returns a new SimpleHTTPClient, retrieving the base URL from the environment and adds a proxy

func (*SimpleHTTPClient) Do

func (c *SimpleHTTPClient) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do the specified http request, decoding the JSON result into v

func (*SimpleHTTPClient) NewRequest

func (c *SimpleHTTPClient) NewRequest(
	ctx context.Context,
	method,
	path string,
	body interface{},
	qsb QueryStringBody,
) (*http.Request, error)

NewRequest wraps the new request with a particular error type

Directories

Path Synopsis
mock
Package mock_bitflyer is a generated GoMock package.
Package mock_bitflyer is a generated GoMock package.
cbr
mock
Package mock_cbr is a generated GoMock package.
Package mock_cbr is a generated GoMock package.
mock
Package mock_coingecko is a generated GoMock package.
Package mock_coingecko is a generated GoMock package.
mock
Package mock_gemini is a generated GoMock package.
Package mock_gemini is a generated GoMock package.
mock
Package mock_ratios is a generated GoMock package.
Package mock_ratios is a generated GoMock package.
mock
Package mock_reputation is a generated GoMock package.
Package mock_reputation is a generated GoMock package.
mock
Package mock_stripe is a generated GoMock package.
Package mock_stripe is a generated GoMock package.

Jump to

Keyboard shortcuts

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