Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPRequest ¶
type HTTPRequest interface {
AddHeader(key string, value string) HTTPRequest
AddHeaders(headers map[string]string) HTTPRequest
AddQuery(key string, value string) HTTPRequest
AddQueryArray(key string, value []string) HTTPRequest
AddBody(body interface{}) HTTPRequest
AddBasicAuth(username string, password string) HTTPRequest
AddBearerAuth(token string) HTTPRequest
SetNamedPathParams(regexp string, values []string) HTTPRequest
Dev() HTTPRequest
DevFromEnv() HTTPRequest
WithCookie(cookie *http.Cookie) HTTPRequest
WithRetries(retries int) HTTPRequest
WithContext(ctx context.Context) HTTPRequest
AddBeforeHook(handler func(req *http.Request)) HTTPRequest
AddAfterHook(handler func(
req *http.Request,
resp *http.Response,
err error)) HTTPRequest
Begin() HTTPRequest
Get() HTTPResponse
Put() HTTPResponse
Del() HTTPResponse
Post() HTTPResponse
Patch() HTTPResponse
Invoke(
ctx context.Context,
method string,
url string,
opt *stdlib.ClientOptions,
body interface{},
) HTTPResponse
}
func Req ¶
func Req(url string) HTTPRequest
type HTTPResponse ¶
type HTTPResponse interface {
GetStatusCode() int
SetResult(responseBody any) error
CatchError() error
Catch(errorObject any) error
IsSuccess() bool
GetTraceInfo() HttpTraceInfo
GetUrl() string
GetMethod() string
GetHeaders() http.Header
GetBody() []byte
GetCookies() []*http.Cookie
GetElapsedTime() time.Duration
}
type HttpTraceInfo ¶
type HttpTraceInfo struct {
// DNSLookupTime is a duration that transport took to perform
// DNS lookup.
DNSLookupTime time.Duration
// ConnectTime is a duration that took to obtain a successful connection.
ConnectTime time.Duration
// TCPConnectTime is a duration that took to obtain the TCP connection.
TCPConnectTime time.Duration
// TLSHandshakeTime is a duration that TLS handshake took place.
TLSHandshakeTime time.Duration
// FirstResponseTime is a duration that server took to respond first byte since
// connection ready (after tls handshake if it's tls and not a reused connection).
FirstResponseTime time.Duration
// ResponseTime is a duration since first response 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
// RemoteAddr returns the remote network address.
RemoteAddr net.Addr
}
type RetryOptions ¶
Click to show internal directories.
Click to hide internal directories.