api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

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

func NewBaseClient

func NewBaseClient(baseURL string, opts ...Option) *BaseClient

func (*BaseClient) CheckStatus

func (c *BaseClient) CheckStatus(resp *http.Response) error

CheckStatus returns nil for 200 OK responses. For all other status codes, it drains the response body (for TCP connection reuse) and returns an *HTTPError.

func (*BaseClient) DoGet

func (c *BaseClient) DoGet(ctx context.Context, path string) (*http.Response, error)

func (*BaseClient) DoPost

func (c *BaseClient) DoPost(ctx context.Context, path string, payload any) (*http.Response, error)

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       []byte
}

HTTPError represents a non-OK HTTP response.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Option added in v1.0.0

type Option func(*BaseClient)

Option configures a BaseClient.

func WithHeader added in v1.0.0

func WithHeader(key, value string) Option

WithHeader adds a default header to all requests.

Jump to

Keyboard shortcuts

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