xhttpclient

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoundTripper

func NewRoundTripper(t *Transport, c ...Constructor) http.RoundTripper

NewRoundTripper assembles an http.RoundTripper given a set of configuration options. The returned round tripper will be backed by an http.Transport, decorated with any constructors that were supplied. If the Transport options is nil, a default http.Transport is used.

func NewTlsConfig

func NewTlsConfig(tc *Tls) *tls.Config

NewTlsConfig assembles a *tls.Config for clients given a set of configuration options. If the Tls options is nil, this method returns nil, nil.

func Unmarshal

func Unmarshal(configKey string, c ...Constructor) func(ClientUnmarshalIn) (Interface, error)

Unmarshal returns an uber/fx provider than in turn unmarshals client options and produces a client object. If multiple client objects need to coexist in the same uber/fx App, use fx.Annotated with this function.

Types

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain is a sequence of Constructors, just like github.com/justinas/alice.Chain

func NewChain

func NewChain(c ...Constructor) Chain

func (Chain) Append

func (ch Chain) Append(more ...Constructor) Chain

func (Chain) Extend

func (ch Chain) Extend(more Chain) Chain

func (Chain) Then

func (ch Chain) Then(rt http.RoundTripper) http.RoundTripper

func (Chain) ThenFunc

func (ch Chain) ThenFunc(rtf RoundTripperFunc) http.RoundTripper

type ClientUnmarshalIn

type ClientUnmarshalIn struct {
	fx.In

	Unmarshaller config.Unmarshaller

	// Chain is an optional component.  If present in the application, this chain
	// will be used to decorate the roundtripper.  Any constructors passed to Unmarshal
	// will be appended to this chain.
	//
	// Using this component allows for global decorators that apply to all clients.
	Chain Chain `optional:"true"`
}

ClientUnmarshalIn defines the set of dependencies for an HTTP client

type Constructor

type Constructor func(http.RoundTripper) http.RoundTripper

Constructor is an Alice-style constructor for RoundTrippers

type Interface

type Interface interface {
	Do(*http.Request) (*http.Response, error)
}

Interface defines the behavior of an HTTP client. *http.Client implements this interface.

func New

func New(o Options, c ...Constructor) Interface

New assembles an http client from a set of configuration options

type Options

type Options struct {
	Timeout   time.Duration
	Transport *Transport
}

Options represents the set of configurable options for an HTTP client

type RequestHeaders

type RequestHeaders struct {
	Header http.Header
}

RequestHeaders provides a RoundTripper constructor that inserts a constant set of headers into each request

func (RequestHeaders) Then

func (RequestHeaders) ThenFunc

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

func (RoundTripperFunc) RoundTrip

func (rtf RoundTripperFunc) RoundTrip(request *http.Request) (*http.Response, error)

type Tls

type Tls struct {
	InsecureSkipVerify bool
}

Tls represents the set of configurable options for client-side TLS

type Transport

type Transport struct {
	DisableKeepAlives      bool
	DisableCompression     bool
	MaxIdleConns           int
	MaxIdleConnsPerHost    int
	MaxConnsPerHost        int
	IdleConnTimeout        time.Duration
	ResponseHeaderTimeout  time.Duration
	ExpectContinueTimeout  time.Duration
	MaxResponseHeaderBytes int64
	TlsHandshakeTimeout    time.Duration
	Tls                    *Tls

	// Header is a set of static HTTP headers added to every request
	Header http.Header
}

Transport represents the set of configurable options for a client RoundTripper The majority of these fields map directory to an http.Transport. See https://godoc.org/net/http#Transport

Jump to

Keyboard shortcuts

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