config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 5 Imported by: 87

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPreDefinedOpts

func SetPreDefinedOpts(opts ...RequestOption)

Pre define some RequestOption here

Types

type ClientOption

type ClientOption struct {
	F func(o *ClientOptions)
}

ClientOption is the only struct that can be used to set ClientOptions.

type ClientOptions

type ClientOptions struct {
	// Timeout for establishing a connection to server
	DialTimeout time.Duration
	// The max connection nums for each host
	MaxConnsPerHost int

	MaxIdleConnDuration       time.Duration
	MaxConnDuration           time.Duration
	MaxConnWaitTimeout        time.Duration
	MaxIdempotentCallAttempts int
	KeepAlive                 bool
	ReadTimeout               time.Duration
	TLSConfig                 *tls.Config
	ResponseBodyStream        bool

	// Client name. Used in User-Agent request header.
	//
	// Default client name is used if not set.
	Name string

	// NoDefaultUserAgentHeader when set to true, causes the default
	// User-Agent header to be excluded from the Request.
	NoDefaultUserAgentHeader bool

	// Callback for establishing new connections to hosts.
	//
	// Default Dial is used if not set.
	Dial func(addr string) (network.Conn, error)

	// Attempt to connect to both ipv4 and ipv6 addresses if set to true.
	//
	// This option is used only if default TCP dialer is used,
	// i.e. if Dial is blank.
	//
	// By default client connects only to ipv4 addresses,
	// since unfortunately ipv6 remains broken in many networks worldwide :)
	DialDualStack bool

	// Maximum duration for full request writing (including body).
	//
	// By default request write timeout is unlimited.
	WriteTimeout time.Duration

	// Maximum response body size.
	//
	// The client returns ErrBodyTooLarge if this limit is greater than 0
	// and response body is greater than the limit.
	//
	// By default response body size is unlimited.
	MaxResponseBodySize int

	// Header names are passed as-is without normalization
	// if this option is set.
	//
	// Disabled header names' normalization may be useful only for proxying
	// responses to other clients expecting case-sensitive header names.
	//
	// By default request and response header names are normalized, i.e.
	// The first letter and the first letters following dashes
	// are uppercased, while all the other letters are lowercased.
	// Examples:
	//
	//     * HOST -> Host
	//     * content-type -> Content-Type
	//     * cONTENT-lenGTH -> Content-Length
	DisableHeaderNamesNormalizing bool

	// Path values are sent as-is without normalization
	//
	// Disabled path normalization may be useful for proxying incoming requests
	// to servers that are expecting paths to be forwarded as-is.
	//
	// By default path values are normalized, i.e.
	// extra slashes are removed, special characters are encoded.
	DisablePathNormalizing bool
}

func NewClientOptions

func NewClientOptions(opts []ClientOption) *ClientOptions

func (*ClientOptions) Apply

func (o *ClientOptions) Apply(opts []ClientOption)

type Option

type Option struct {
	F func(o *Options)
}

Option is the only struct that can be used to set Options.

type Options

type Options struct {
	KeepAliveTimeout             time.Duration
	ReadTimeout                  time.Duration
	IdleTimeout                  time.Duration
	RedirectTrailingSlash        bool
	MaxRequestBodySize           int
	MaxKeepBodySize              int
	GetOnly                      bool
	DisableKeepalive             bool
	RedirectFixedPath            bool
	HandleMethodNotAllowed       bool
	UseRawPath                   bool
	RemoveExtraSlash             bool
	UnescapePathValues           bool
	DisablePreParseMultipartForm bool
	StreamRequestBody            bool
	NoDefaultServerHeader        bool
	Network                      string
	Addr                         string
	ExitWaitTimeout              time.Duration
	TLS                          *tls.Config
	H2C                          bool
	ReadBufferSize               int
	ALPN                         bool
	Tracers                      []interface{}
	TraceLevel                   interface{}
	ListenConfig                 *net.ListenConfig
}

func NewOptions

func NewOptions(opts []Option) *Options

func (*Options) Apply

func (o *Options) Apply(opts []Option)

type RequestOption

type RequestOption struct {
	F func(o *RequestOptions)
}

RequestOption 是唯一可以用来设置 RequestOption 的类.

func WithSD

func WithSD(b bool) RequestOption

WithSD set isSD in RequestOptions.

func WithTag

func WithTag(k, v string) RequestOption

WithTag set tag in RequestOptions.

type RequestOptions

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

func NewRequestOptions

func NewRequestOptions(opts []RequestOption) *RequestOptions

NewRequestOptions create a *RequestOptions according to the given opts

func (*RequestOptions) Apply

func (o *RequestOptions) Apply(opts []RequestOption)

func (*RequestOptions) CopyTo

func (o *RequestOptions) CopyTo(dst *RequestOptions)

func (*RequestOptions) IsSD

func (o *RequestOptions) IsSD() bool

func (*RequestOptions) Tag

func (o *RequestOptions) Tag(k string) string

Jump to

Keyboard shortcuts

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