client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

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

Chain is an immutable sequence of constructors. This type is essentially a bundle of middleware for HTTP clients.

func NewChain

func NewChain(ctors ...Constructor) (c Chain)

NewChain creates a chain from a sequence of constructors. The constructors are always applied in the order presented here.

func (Chain) Append

func (c Chain) Append(more ...Constructor) (nc Chain)

Append adds additional Constructors to this chain, and returns the new chain. This chain is not modified. If more has zero length, this chain is returned.

func (Chain) Extend

func (c Chain) Extend(more Chain) Chain

Extend is like Append, except that the additional Constructors come from another chain

func (Chain) Then

func (c Chain) Then(next httpaux.Client) httpaux.Client

Then applies the given sequence of middleware to the next httpaux.Client.

func (Chain) ThenFunc

func (c Chain) ThenFunc(next Func) httpaux.Client

ThenFunc makes it easier to use a client transactor Func as the HTTP client

type Constructor

type Constructor func(httpaux.Client) httpaux.Client

Constructor applies clientside middleware to an HTTP client, as implemented by httpaux.Client.

func Header(hf func(http.Header)) Constructor

Header adds a middleware Constructor that uses a closure to modify each request header. Both httpaux.Header.SetTo and httpaux.Header.AddTo can be used as this closure.

type Func

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

Func is an HTTP client function type

func (Func) Do

func (f Func) Do(request *http.Request) (*http.Response, error)

Do fulfills the httpaux.Client interface and permits this function to be used like an HTTP client.

Jump to

Keyboard shortcuts

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