http_client

package
v1.27.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHTTPAgentErrorStatusOf added in v1.2.0

func IsHTTPAgentErrorStatusOf(err error, status int) (*types.AgentError, bool)

func NewAuthenticatedTransport

func NewAuthenticatedTransport(base http.RoundTripper, auth auth.AuthMethod) http.RoundTripper

func NewTransport added in v1.19.0

func NewTransport() *http.Transport

Types

type AuthenticatedTransport

type AuthenticatedTransport struct {
	// contains filtered or unexported fields
}

func (*AuthenticatedTransport) RoundTrip

func (t *AuthenticatedTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip authenticates the request before sending it.

type HTTPClient

type HTTPClient interface {
	GetRaw(path string, log logging.Logger) ([]byte, error)
	PostRaw(path string, body io.Reader, bodyType string, log logging.Logger) ([]byte, error)
	Get(path string, into any, log logging.Logger) error
	Post(path string, body any, into any, log logging.Logger) error
	PostForm(path string, data url.Values, into any, log logging.Logger) error
	Put(path string, body any, into any, log logging.Logger) error
	Patch(path string, body any, into any, log logging.Logger) error
	Delete(path string, log logging.Logger) error
}

func NewBasicHTTPClient added in v1.18.1

func NewBasicHTTPClient(baseURL string, timeout time.Duration) HTTPClient

func NewBasicHTTPClientWithBearerAuth added in v1.19.0

func NewBasicHTTPClientWithBearerAuth(baseURL string, timeout time.Duration, authValue string) HTTPClient

func NewDefaultHTTPClient

func NewDefaultHTTPClient(account *accounts.Account, timeout time.Duration, log logging.Logger) (HTTPClient, error)

type HTTPClientWithBearerAuthFactory added in v1.19.0

type HTTPClientWithBearerAuthFactory func(baseURL string, timeout time.Duration, authValue string) HTTPClient

type HTTPError

type HTTPError struct {
	URL    string `mapstructure:"url"`
	Method string `mapstructure:"method"`
	Status int    `mapstructure:"status"`
	Body   string `mapstructure:"body"`
}

func NewHTTPError

func NewHTTPError(url, method string, status int, body string) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type MockHTTPClient

type MockHTTPClient struct {
	mock.Mock
}

func (*MockHTTPClient) Delete

func (m *MockHTTPClient) Delete(path string, log logging.Logger) error

func (*MockHTTPClient) Get

func (m *MockHTTPClient) Get(path string, into any, log logging.Logger) error

func (*MockHTTPClient) GetRaw

func (m *MockHTTPClient) GetRaw(path string, log logging.Logger) ([]byte, error)

func (*MockHTTPClient) Patch

func (m *MockHTTPClient) Patch(path string, body any, into any, log logging.Logger) error

func (*MockHTTPClient) Post

func (m *MockHTTPClient) Post(path string, body any, into any, log logging.Logger) error

func (*MockHTTPClient) PostForm added in v1.18.1

func (m *MockHTTPClient) PostForm(path string, data url.Values, into any, log logging.Logger) error

func (*MockHTTPClient) PostRaw

func (m *MockHTTPClient) PostRaw(path string, body io.Reader, bodyType string, log logging.Logger) ([]byte, error)

func (*MockHTTPClient) Put

func (m *MockHTTPClient) Put(path string, body any, into any, log logging.Logger) error

Jump to

Keyboard shortcuts

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