http

package
v0.64.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 9 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 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
	UserAgent string
}

Options configures the transport settings

Jump to

Keyboard shortcuts

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