http

package
v0.68.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(opts ...ClientOption) *http.Client

func ClientWithContext

func ClientWithContext(ctx context.Context, opts ...ClientOption) *http.Client

ClientWithContext returns an HTTP client with the specified context and options.

func NewTraceTransport added in v0.65.0

func NewTraceTransport(inner http.RoundTripper, opts ...TraceOption) http.RoundTripper

NewTraceTransport returns an http.RoundTripper that logs HTTP requests and responses

func NewTransport

func NewTransport(opts Options) http.RoundTripper

NewTransport creates a new HTTP transport with the specified options. It should be used to initialize the default transport. In most cases, you should use the `Transport` function to get the default transport.

func NewUserAgent

func NewUserAgent(inner http.RoundTripper, ua string) http.RoundTripper

NewUserAgent returns an http.Roundtripper that sets the user agent

User-Agent: trivy/v0.64.0

func SetDefaultTransport

func SetDefaultTransport(tr http.RoundTripper)

SetDefaultTransport sets the default transport configuration

func Transport

func Transport(ctx context.Context) http.RoundTripper

Transport returns the transport from the context, or the default transport if none is set.

func WithTransport

func WithTransport(ctx context.Context, tr http.RoundTripper) context.Context

WithTransport returns a new context with the given transport. This is mainly for testing when a different HTTP transport needs to be used.

Types

type ClientOption

type ClientOption func(client *http.Client)

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

type Options

type Options struct {
	Insecure  bool
	Timeout   time.Duration
	CACerts   *x509.CertPool
	UserAgent string
	TraceHTTP bool
}

Options configures the transport settings

type TraceOption added in v0.65.0

type TraceOption func(*traceTransport)

TraceOption is a functional option for traceTransport

func WithWriter added in v0.65.0

func WithWriter(w io.Writer) TraceOption

WithWriter sets the writer for trace output

Jump to

Keyboard shortcuts

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