httpclient

package
v0.0.0-...-26f4575 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(options ...ClientOption) *http.Client

NewClient returns a new Client.

func NewClientWithTransport

func NewClientWithTransport(transport http.RoundTripper) *http.Client

NewClientWithTransport returns a new Client with the given transport. This is a separate constructor so that it's clear it cannot be used in combination with other ClientOptions.

Types

type ClientInterceptorFunc

type ClientInterceptorFunc func(http.RoundTripper) http.RoundTripper

ClientInterceptorFunc is a function that wraps a RoundTripper with any interceptors

type ClientOption

type ClientOption func(*clientOptions)

ClientOption is an option for a new Client.

func WithH2C

func WithH2C() ClientOption

WithH2C returns a new ClientOption that allows dialing h2c (cleartext) servers.

func WithInterceptorFunc

func WithInterceptorFunc(interceptorFunc ClientInterceptorFunc) ClientOption

WithInterceptorFunc returns a new ClientOption to use a given interceptor.

func WithProxy

func WithProxy(proxyFunc Proxy) ClientOption

WithProxy returns a new ClientOption to use a proxy.

The default is to use http.ProxyFromEnvironment

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) ClientOption

WithTLSConfig returns a new ClientOption to use the tls.Config.

The default is to use no TLS.

type Proxy

type Proxy func(req *http.Request) (*url.URL, error)

Proxy specifies a function to return a proxy for a given Request. If the function returns a non-nil error, the request is aborted with the provided error.

Jump to

Keyboard shortcuts

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