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 NewUserAgent(inner http.RoundTripper, ua string) http.RoundTripper
- func RoundTripper(ctx context.Context, opts ...TransportOption) http.RoundTripper
- func SetDefaultTransport(t Transport)
- func WithTransport(ctx context.Context, t Transport) context.Context
- type ClientOption
- type Options
- type TraceOption
- type Transport
- type TransportOption
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
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
type Transport ¶
type Transport interface {
Build(opts ...TransportOption) http.RoundTripper
}
Transport is an interface for building an http.RoundTripper.
func NewTransport ¶
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
TransportOption modifies an *http.Transport.
func WithInsecure ¶ added in v0.69.0
func WithInsecure(insecure bool) TransportOption
WithInsecure returns a TransportOption that sets InsecureSkipVerify.