client

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

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) (*http.Request, error)
	Do(req *http.Request) (*http.Response, error)
	Get(ctx context.Context, url string, opts ...RequestOption) (*http.Response, error)
	PostJSON(ctx context.Context, url string, body any, opts ...RequestOption) (*http.Response, error)
}

func New

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

type Option

type Option func(*client)

func WithCert

func WithCert(cert certutil.CertBundle, authType tls.ClientAuthType) Option

func WithDebug

func WithDebug() Option

func WithLogger

func WithLogger(logger log.Logger) Option

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
}

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 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