slackhttp

package
v0.0.0-...-113aa42 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockHTTPResponse

func MockHTTPResponse(httpStatus int, body string) *http.Response

MockHTTPResponse is a helper that returns a mocked http.Response with the provided httpStatus and body.

func NewHTTPClient

func NewHTTPClient(opts HTTPClientOptions) *http.Client

NewHTTPClient returns an http.Client configured with HTTPClientOptions.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
	Get(url string) (*http.Response, error)
	Head(url string) (*http.Response, error)
}

HTTPClient interface for http.Client.

type HTTPClientMock

type HTTPClientMock struct {
	mock.Mock
}

HTTPClientMock implements a mock for the HTTPClient interface.

func (*HTTPClientMock) Do

func (m *HTTPClientMock) Do(req *http.Request) (*http.Response, error)

Do is a mock that tracks the calls to Do and returns the mocked http.Response and error.

func (*HTTPClientMock) Get

func (m *HTTPClientMock) Get(url string) (*http.Response, error)

Get is a mock that tracks the calls to Get and returns the mocked http.Response and error.

func (*HTTPClientMock) Head

func (m *HTTPClientMock) Head(url string) (*http.Response, error)

Head is a mock that tracks the calls to Head and returns the mocked http.Response and error.

type HTTPClientOptions

type HTTPClientOptions struct {
	AttemptTimeout   *time.Duration // AttemptTimeout is how long each request waits before cancelled.
	Backoff          *time.Duration // Backoff is a constant duration to wait between requests.
	Retries          int            // Retries for a request, if 0 then no retry logic is added.
	RetryErrorCodes  []string       // RetryErrorCode is list of error codes to retry on.
	RetryStatusCodes []int          // RetryStatusCode is list of http status codes to retry on.
	SkipTLSVerify    bool           // SkipTLSVerify will skip verifying the host's certificate.
	TotalTimeOut     time.Duration  // TotalTimeOut for the life of the request (default: defaultTotalTimeout).
}

HTTPClientOptions allows for the customization of a http.Client.

Jump to

Keyboard shortcuts

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