client

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: Apache-2.0 Imports: 9 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 {
	Get(ctx context.Context, url string) (*http.Response, error)
	Post(ctx context.Context, url string, body io.Reader) (*http.Response, error)
	Put(ctx context.Context, url string, body io.Reader) (*http.Response, error)
	Delete(ctx context.Context, url string) (*http.Response, error)

	Options() Options
	Close()
}

func New

func New(opts ...Option) Client

type ErrorParser

type ErrorParser func(status string, reader io.Reader) error

type Option

type Option func(*options)

func WithBasicAuth

func WithBasicAuth(user, pass string) Option

func WithClientCA

func WithClientCA(ca *x509.CertPool) Option

func WithErrorParser

func WithErrorParser(p ErrorParser) Option

func WithHost

func WithHost(h string) Option

func WithInsecure

func WithInsecure() Option

func WithPlainHTTP

func WithPlainHTTP() Option

func WithTransport

func WithTransport(t http.RoundTripper) Option

func WithUserAgent

func WithUserAgent(ua string) Option

type Options

type Options interface {
	Scheme() string
	Host() string
	PlainHTTP() bool
	Insecure() bool
	CA() *x509.CertPool
	BasicAuth() (username, password string, ok bool)
}

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

func (RoundTripperFunc) RoundTrip

func (f RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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