requestconfig

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteNewRequest

func ExecuteNewRequest(ctx context.Context, method string, u string, body interface{}, dst interface{}, opts ...RequestOption) error

func UseDefaultParam added in v1.6.3

func UseDefaultParam[T any](dst *param.Field[T], src *T)

Types

type HTTPDoer added in v1.13.0

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

This interface is primarily used to describe an *http.Client, but also supports custom HTTP implementations.

type PreRequestOptionFunc added in v1.6.3

type PreRequestOptionFunc func(*RequestConfig) error

func (PreRequestOptionFunc) Apply added in v1.6.3

type RequestConfig

type RequestConfig struct {
	MaxRetries     int
	RequestTimeout time.Duration
	Context        context.Context
	Request        *http.Request
	BaseURL        *url.URL
	CustomHTTPDoer HTTPDoer
	HTTPClient     *http.Client
	Middlewares    []middleware
	BearerToken    string
	// If ResponseBodyInto not nil, then we will attempt to deserialize into
	// ResponseBodyInto. If Destination is a []byte, then it will return the body as
	// is.
	ResponseBodyInto interface{}
	// ResponseInto copies the \*http.Response of the corresponding request into the
	// given address
	ResponseInto **http.Response
	Body         io.Reader
}

RequestConfig represents all the state related to one request.

Editing the variables inside RequestConfig directly is unstable api. Prefer composing the RequestOption instead if possible.

func NewRequestConfig

func NewRequestConfig(ctx context.Context, method string, u string, body interface{}, dst interface{}, opts ...RequestOption) (*RequestConfig, error)

func PreRequestOptions added in v1.6.3

func PreRequestOptions(opts ...RequestOption) (RequestConfig, error)

func (*RequestConfig) Apply

func (cfg *RequestConfig) Apply(opts ...RequestOption) error

func (*RequestConfig) Clone

func (cfg *RequestConfig) Clone(ctx context.Context) *RequestConfig

func (*RequestConfig) Execute

func (cfg *RequestConfig) Execute() (err error)

type RequestOption added in v1.6.3

type RequestOption interface {
	Apply(*RequestConfig) error
}

type RequestOptionFunc added in v1.6.3

type RequestOptionFunc func(*RequestConfig) error

func (RequestOptionFunc) Apply added in v1.6.3

Jump to

Keyboard shortcuts

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