client

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 16 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	common.Initializable
	SetHeaders(headers ...common.Pair[string, string])
	SetCookies(cookies ...*http.Cookie)
	NewRequest(ctx context.Context, request *Request, opts ...RequestOption) (*http.Request, error)
	Do(req *http.Request) (*http.Response, error)
	Send(ctx context.Context, request *Request, opts ...RequestOption) (*http.Response, error)
}

func New

func New(endpoint string, opts ...Option) Client

type Option

type Option func(*client)

func WithDebug

func WithDebug() Option

func WithLogger

func WithLogger(logger log.Logger) Option

func WithTLS added in v0.9.0

func WithTLS(cert certutil.CertBundle, rootCAs ...*x509.Certificate) Option

WithTLS presents cert, when not nil, and verifies the server against rootCAs, the system's when none.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Request

type Request struct {
	Method      string
	Path        string
	Headers     common.Pairs
	Cookies     []*http.Cookie
	ContentType string
	Body        any
	Encoding    api.Encoding
}

func (*Request) ParseBody

func (r *Request) ParseBody() (io.Reader, error)

type RequestOption

type RequestOption func(*Request)

func WithRequestCookies

func WithRequestCookies(cookies ...*http.Cookie) RequestOption

func WithRequestEncoding added in v0.4.0

func WithRequestEncoding(encoding api.Encoding) RequestOption

func WithRequestHeaders

func WithRequestHeaders(headers ...common.Pair[string, string]) RequestOption

Jump to

Keyboard shortcuts

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