client

package
v1.69.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(ctx context.Context, opts ...HTTPOption) *http.Client

NewHTTPClient creates a new HTTP client with the provided options. If no transport is specified, it defaults to otelhttp.NewTransport(http.DefaultTransport).

func NewLoggingTransport added in v1.65.7

func NewLoggingTransport(transport http.RoundTripper, opts ...LoggingTransportOption) http.RoundTripper

NewLoggingTransport creates a new logging HTTP transport. By default, it logs requests and responses but not headers or body for security.

func WrapClient added in v1.65.7

func WrapClient(client *http.Client, opts ...LoggingTransportOption) *http.Client

WrapClient wraps an existing HTTP client with logging transport.

Types

type HTTPOption

type HTTPOption func(*httpConfig)

HTTPOption configures HTTP client behavior. It can be used to configure timeout, transport, and other HTTP client settings.

func WithHTTPCheckRedirect

func WithHTTPCheckRedirect(checkRedirect func(req *http.Request, via []*http.Request) error) HTTPOption

WithHTTPCheckRedirect sets the redirect policy.

func WithHTTPClientCredentials added in v1.66.2

func WithHTTPClientCredentials(cfg *clientcredentials.Config) HTTPOption

WithHTTPClientCredentials the client credentials the client can utilize.

func WithHTTPCookieJar

func WithHTTPCookieJar(jar http.CookieJar) HTTPOption

WithHTTPCookieJar sets the cookie jar.

func WithHTTPEnableH2C added in v1.66.2

func WithHTTPEnableH2C() HTTPOption

WithHTTPEnableH2C sets the enable h2c option to active.

func WithHTTPIdleTimeout

func WithHTTPIdleTimeout(timeout time.Duration) HTTPOption

WithHTTPIdleTimeout sets the idle timeout.

func WithHTTPTimeout

func WithHTTPTimeout(timeout time.Duration) HTTPOption

WithHTTPTimeout sets the request timeout.

func WithHTTPTraceRequestHeaders added in v1.65.7

func WithHTTPTraceRequestHeaders() HTTPOption

WithHTTPTraceRequestHeaders enables or disables header logging.

func WithHTTPTraceRequests added in v1.65.7

func WithHTTPTraceRequests() HTTPOption

WithHTTPTraceRequests enables or disables request logging.

func WithHTTPTransport

func WithHTTPTransport(transport http.RoundTripper) HTTPOption

WithHTTPTransport sets the HTTP transport.

type LoggingTransportOption added in v1.65.7

type LoggingTransportOption func(*loggingTransport)

LoggingTransportOption configures the logging HTTP transport.

func WithTransportLogBody added in v1.65.7

func WithTransportLogBody(enabled bool) LoggingTransportOption

WithTransportLogBody enables or disables body logging. Note: Be careful when enabling this as bodies may contain sensitive information or be large.

func WithTransportLogHeaders added in v1.65.7

func WithTransportLogHeaders(enabled bool) LoggingTransportOption

WithTransportLogHeaders enables or disables header logging. Note: Be careful when enabling this as headers may contain sensitive information.

func WithTransportLogRequests added in v1.65.7

func WithTransportLogRequests(enabled bool) LoggingTransportOption

WithTransportLogRequests enables or disables request logging.

func WithTransportLogResponses added in v1.65.7

func WithTransportLogResponses(enabled bool) LoggingTransportOption

WithTransportLogResponses enables or disables response logging.

func WithTransportMaxBodySize added in v1.65.7

func WithTransportMaxBodySize(size int64) LoggingTransportOption

WithTransportMaxBodySize sets the maximum body size to log.

type Manager added in v1.63.0

type Manager interface {
	Client(ctx context.Context) *http.Client
	SetClient(ctx context.Context, cl *http.Client)

	Invoke(ctx context.Context,
		method string, endpointURL string, payload map[string]any,
		headers map[string][]string, opts ...HTTPOption) (int, []byte, error)
	InvokeWithURLEncoded(ctx context.Context,
		method string, endpointURL string, payload url.Values,
		headers map[string]string, opts ...HTTPOption) (int, []byte, error)
}

func NewManager added in v1.63.0

func NewManager(ctx context.Context, opts ...HTTPOption) Manager

NewManager creates a new invoker with the provided options.

Jump to

Keyboard shortcuts

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