common

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilClient is an error returned when a given HTTPClient is nil.
	ErrNilClient = errors.New("given client is nil")
)

Functions

func GetEndp

func GetEndp(client HTTPClient, endp string, params, dst any, opts ...Option) error

GetEndp is an internal function, working as a helper.

Types

type ErrUnexpectedStatus

type ErrUnexpectedStatus struct {
	Body       []byte
	StatusCode int
}

ErrUnexpectedStatus is an error meaning the API call returned a response with an unexpected status. It may occurs when the server is down or the parameters/body is invalid.

func (ErrUnexpectedStatus) Error

func (e ErrUnexpectedStatus) Error() string

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient defines what is the basic implementation of an HTTP client. Used for interconnectability with various implementations of an HTTP client, and for mocking purposes.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey defines the API keyto use when executing the HTTP request. Default won't set the HTTP header in the request.

func WithContext

func WithContext(ctx context.Context) Option

WithContext defines the context to use when executing the HTTP request. Default is context.Background.

Jump to

Keyboard shortcuts

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