http

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 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 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 RoundTripper added in v0.69.0

func RoundTripper(ctx context.Context, opts ...TransportOption) http.RoundTripper

RoundTripper returns the http.RoundTripper from the context, or builds one from the default transport. TransportOptions can be used to override the base transport settings for the returned http.RoundTripper only; they do not modify the default transport or the transport stored in the context.

func SetDefaultTransport

func SetDefaultTransport(t Transport)

SetDefaultTransport sets the default transport configuration

func WithTransport

func WithTransport(ctx context.Context, t Transport) 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

type Transport

type Transport interface {
	Build(opts ...TransportOption) http.RoundTripper
}

Transport is an interface for building an http.RoundTripper.

func NewTransport

func NewTransport(opts Options) Transport

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

type TransportOption added in v0.69.0

type TransportOption func(*http.Transport)

TransportOption modifies an *http.Transport.

func WithInsecure added in v0.69.0

func WithInsecure(insecure bool) TransportOption

WithInsecure returns a TransportOption that sets InsecureSkipVerify.

Jump to

Keyboard shortcuts

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