http

package
v0.0.0-...-0cbe00f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRetryCount represents how many time to retry a HTTP request by default.
	// We will start with no retry.
	DefaultRetryCount = 0

	// DefaultHTTPTimeout is the timeout for HTTP requests.
	DefaultHTTPTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(config *ClientConfig) *httpClient

NewClient creates a new HTTP client.

Types

type Client

type Client interface {
	Request(method string, url string, params, result interface{}) (res *http.Response, err error)
	RequestAddHeaders(method string, url string,
		headers *map[string]string, params, result interface{}) (res *http.Response, err error)
}

Make http easy to mock for unit testing

type ClientConfig

type ClientConfig struct {
	BaseURL    string
	RetryCount int
	Timeout    time.Duration
}

ClientConfig contains configurations to construct a client.

type Error

type Error struct {
	Message string `json:"message"`
}

func (Error) Error

func (e Error) Error() string

Error implements the built-in error interface type.

Jump to

Keyboard shortcuts

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