httpcli

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientTimeout30Sec = 30 * time.Second
	ClientTimeout10Sec = 10 * time.Second
	ClientTimeout5Sec  = 5 * time.Second
	ClientTimeout1Sec  = 1 * time.Second

	ClientNetworkTCP = "tcp"
	ClientNetworkUDP = "udp"
)
View Source
const (
	ErrorParamEmpty liberr.CodeError = iota + liberr.MinPkgHttpCli
	ErrorParamInvalid
	ErrorValidatorError
	ErrorClientTransportHttp2
)

Variables

This section is empty.

Functions

func DefaultConfig added in v1.10.0

func DefaultConfig(indent string) []byte

func GetClient

func GetClient(serverName string) *http.Client

func GetClientCustom added in v1.4.5

func GetClientCustom(tr *http.Transport, http2Tr bool, GlobalTimeout time.Duration) (*http.Client, liberr.Error)

func GetClientError

func GetClientError(serverName string) (*http.Client, liberr.Error)

func GetClientTimeout

func GetClientTimeout(serverName string, http2Tr bool, GlobalTimeout time.Duration) (*http.Client, liberr.Error)

func GetClientTls added in v1.9.0

func GetClientTls(serverName string, tls libtls.TLSConfig, http2Tr bool, GlobalTimeout time.Duration) (*http.Client, liberr.Error)

func GetClientTlsForceIp added in v1.9.0

func GetClientTlsForceIp(netw Network, ip string, serverName string, tls libtls.TLSConfig, http2Tr bool, GlobalTimeout time.Duration) (*http.Client, liberr.Error)

Types

type FctHttpClient added in v1.10.0

type FctHttpClient func() *http.Client

type Network added in v1.9.0

type Network uint8
const (
	NetworkTCP Network = iota
	NetworkUDP
)

func GetNetworkFromString added in v1.9.0

func GetNetworkFromString(str string) Network

func (Network) Code added in v1.9.0

func (n Network) Code() string

func (Network) String added in v1.9.0

func (n Network) String() string

type OptionForceIP added in v1.9.0

type OptionForceIP struct {
	Enable bool   `json:"enable" yaml:"enable" toml:"enable" mapstructure:"enable"`
	Net    string `json:"net,omitempty" yaml:"net,omitempty" toml:"net,omitempty" mapstructure:"net,omitempty"`
	IP     string `json:"ip,omitempty" yaml:"ip,omitempty" toml:"ip,omitempty" mapstructure:"ip,omitempty"`
}

type OptionTLS added in v1.9.0

type OptionTLS struct {
	Enable bool          `json:"enable" yaml:"enable" toml:"enable" mapstructure:"enable"`
	Config libtls.Config `json:"tls" yaml:"tls" toml:"tls" mapstructure:"tls"`
}

type Options added in v1.9.0

type Options struct {
	Timeout time.Duration `json:"timeout" yaml:"timeout" toml:"timeout" mapstructure:"timeout"`
	Http2   bool          `json:"http2" yaml:"http2" toml:"http2" mapstructure:"http2"`
	TLS     OptionTLS     `json:"tls" yaml:"tls" toml:"tls" mapstructure:"tls"`
	ForceIP OptionForceIP `json:"force_ip" yaml:"force_ip" toml:"force_ip" mapstructure:"force_ip"`
}

func (Options) GetClient added in v1.9.0

func (o Options) GetClient(def libtls.TLSConfig, servername string) (*http.Client, liberr.Error)

func (Options) Validate added in v1.9.0

func (o Options) Validate() liberr.Error

Jump to

Keyboard shortcuts

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