httpclient

package
v0.0.0-...-1b4d16b Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoResult

func DoResult[T any](r *Request, ctx context.Context) (T, error)

DoResult executes the request and JSON-decodes the response body into T.

Types

type HttpClient

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

func New

func New() *HttpClient

func (*HttpClient) Delete

func (c *HttpClient) Delete(endpoint string) *Request

func (*HttpClient) Get

func (c *HttpClient) Get(endpoint string) *Request

func (*HttpClient) NewRequest

func (c *HttpClient) NewRequest(method, endpoint string) *Request

func (*HttpClient) Patch

func (c *HttpClient) Patch(endpoint string) *Request

func (*HttpClient) Post

func (c *HttpClient) Post(endpoint string) *Request

func (*HttpClient) Put

func (c *HttpClient) Put(endpoint string) *Request

func (*HttpClient) WithBaseURL

func (c *HttpClient) WithBaseURL(baseURL string) *HttpClient

func (*HttpClient) WithHTTPClient

func (c *HttpClient) WithHTTPClient(hc *http.Client) *HttpClient

func (*HttpClient) WithQuery

func (c *HttpClient) WithQuery(query url.Values) *HttpClient

func (*HttpClient) WithRetry

func (c *HttpClient) WithRetry(retry int) *HttpClient

func (*HttpClient) WithTimeout

func (c *HttpClient) WithTimeout(timeout time.Duration) *HttpClient

type Request

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

func (*Request) Body

func (r *Request) Body(body io.Reader) *Request

func (*Request) Do

func (r *Request) Do(ctx context.Context) ([]byte, error)

func (*Request) JSONBody

func (r *Request) JSONBody(v any) *Request

func (*Request) Query

func (r *Request) Query(key, value string) *Request

func (*Request) WithHeader

func (r *Request) WithHeader(key, value string) *Request

func (*Request) WithQuery

func (r *Request) WithQuery(query url.Values) *Request

type StatusError

type StatusError struct {
	Code int
	Body []byte
}

StatusError represents a non-2xx HTTP response.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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