Documentation
¶
Index ¶
- func Client(opts ...ClientOption) *http.Client
- func ClientWithContext(ctx context.Context, opts ...ClientOption) *http.Client
- func NewTraceTransport(inner http.RoundTripper, opts ...TraceOption) http.RoundTripper
- func NewTransport(opts Options) http.RoundTripper
- func NewUserAgent(inner http.RoundTripper, ua string) http.RoundTripper
- func SetDefaultTransport(tr http.RoundTripper)
- func Transport(ctx context.Context) http.RoundTripper
- func WithTransport(ctx context.Context, tr http.RoundTripper) context.Context
- type ClientOption
- type Options
- type TraceOption
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 ¶
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 ¶
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