Documentation ¶
Index ¶
- Constants
- func DefaultPooledTransport() *http.Transport
- func DefaultTransport() *http.Transport
- func StatusCodeIsRedirect(statusCode int) bool
- type Client
- type Config
- type Jar
- func (j *Jar) DecodeGOB(data []byte) error
- func (j *Jar) EncodeGOB() ([]byte, error)
- func (j *Jar) MarshalJSON() ([]byte, error)
- func (j *Jar) Peek(key string) *fasthttp.Cookie
- func (j *Jar) PeekValue(key string) []byte
- func (j *Jar) ReleaseCookie(key string)
- func (j *Jar) UnmarshalJSON(data []byte) error
- type TraceInfo
Constants ¶
const (
DefaultTimeout = 10 * time.Second
)
const Name = "resty"
Variables ¶
This section is empty.
Functions ¶
func DefaultPooledTransport ¶
DefaultPooledTransport returns a new http.Transport with similar default values to http.DefaultTransport. Do not use this for transient transports as it can leak file descriptors over time. Only use this for transports that will be re-used for the same host(s).
func DefaultTransport ¶
DefaultTransport returns a new http.Transport with similar default values to http.DefaultTransport, but with idle connections and keepalives disabled.
func StatusCodeIsRedirect ¶
StatusCodeIsRedirect returns true if the status code indicates a redirect.
Types ¶
type Client ¶
type Client interface { Middleware(mm ...lava.Middleware) Do(ctx context.Context, req *fasthttp.Request) result.Result[*fasthttp.Response] Head(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] Get(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] Delete(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] Post(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] PostForm(ctx context.Context, url string, val url.Values, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] Put(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] Patch(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response] }
Client http client interface
type Config ¶
type Config struct { Trace bool `yaml:"trace"` Timeout time.Duration `yaml:"timeout"` ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` RetryCount uint32 `yaml:"retry_count"` Proxy bool `yaml:"proxy"` Socks5 string `yaml:"socks5"` Insecure bool `yaml:"insecure"` Header map[string]string `yaml:"header"` BaseUrl string `yaml:"base_url"` TargetService string `yaml:"target_service"` Token string `yaml:"token"` JwtToken string `yaml:"jwt_token"` UserAgent string `yaml:"user_agent"` ContentType string `yaml:"content_type"` Accept string `yaml:"accept"` Debug bool `yaml:"debug"` Authentication bool `yaml:"authentication"` GzipRequest bool `yaml:"gzip_request"` MaxConnsPerHost int `yaml:"max_conns_per_host"` MaxIdleConnDuration time.Duration `yaml:"max_idle_conn_duration"` MaxIdemponentCallAttempts int `yaml:"max_idemponent_call_attempts"` ReadBufferSize int `yaml:"read_buffer_size"` WriteBufferSize int `yaml:"write_buffer_size"` MaxResponseBodySize int `yaml:"max_response_body_size"` // contains filtered or unexported fields }
func DefaultCfg ¶
func DefaultCfg() *Config
func (*Config) Build ¶
func (t *Config) Build(mm []lava.Middleware) lava.HandlerFunc
type Jar ¶
type Jar struct {
// contains filtered or unexported fields
}
func (*Jar) MarshalJSON ¶
func (*Jar) ReleaseCookie ¶
func (*Jar) UnmarshalJSON ¶
type TraceInfo ¶
type TraceInfo struct { // DNSLookup is a duration that transport took to perform // DNS lookup. DNSLookup time.Duration // ConnTime is a duration that took to obtain a successful connection. ConnTime time.Duration // TCPConnTime is a duration that took to obtain the TCP connection. TCPConnTime time.Duration // TLSHandshake is a duration that TLS handshake took place. TLSHandshake time.Duration // ServerTime is a duration that server took to respond first byte. ServerTime time.Duration // ResponseTime is a duration since first responseImpl byte from server to // request completion. ResponseTime time.Duration // TotalTime is a duration that total request took end-to-end. TotalTime time.Duration // IsConnReused is whether this connection has been previously // used for another HTTP request. IsConnReused bool // IsConnWasIdle is whether this connection was obtained from an // idle pool. IsConnWasIdle bool // ConnIdleTime is a duration how long the connection was previously // idle, if IsConnWasIdle is true. ConnIdleTime time.Duration // RequestAttempt is to represent the request attempt made during a Resty // request execution flow, including retry count. RequestAttempt uint32 // RemoteAddr returns the remote network address. RemoteAddr net.Addr }
TraceInfo struct is used provide request trace info such as DNS lookup duration, Connection obtain duration, Server processing duration, etc.
Since v2.0.0