Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPMetadata ¶ added in v0.4.2
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 AddBodyRaw(body []byte) HTTPRequest AddBasicAuth(username string, password string) HTTPRequest AddBearerAuth(token string) HTTPRequest SetNamedPathParams(regexp string, values []string) HTTPRequest Dev() HTTPRequest DevFromEnv() HTTPRequest JSON() HTTPRequest WithCookie(cookie *http.Cookie) HTTPRequest WithRetries( policy RetryPolicy, retries int, amount time.Duration, ) HTTPRequest WithContext(ctx context.Context) HTTPRequest WithLogger(logger Logger) HTTPRequest // AddBeforeHook(handler func(req *http.Request) error) HTTPRequest AddAfterHook(handler func( req *http.Request, resp *http.Response, meta HTTPMetadata, err error)) HTTPRequest Begin() HTTPRequest Get() HTTPResponse GetAsync() <-chan HTTPResponse Put() HTTPResponse PutAsync() <-chan HTTPResponse Del() HTTPResponse DelAsync() <-chan HTTPResponse Post() HTTPResponse PostAsync() <-chan HTTPResponse Patch() HTTPResponse PatchAsync() <-chan HTTPResponse Invoke( ctx context.Context, method string, opt *stdlib.ClientOptions, body interface{}, ) HTTPResponse InvokeAsync( ctx context.Context, method string, opt *stdlib.ClientOptions, body interface{}, ) <-chan HTTPResponse New(url string) HTTPRequest }
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 CURL() string CleanUp() }
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 ¶
type RetryPolicy ¶ added in v0.4.2
type RetryPolicy int8
const ( NO_RETRY RetryPolicy = iota EXPONENTIAL_BACKOFF RetryPolicy = iota CONSTANT_BACKOFF RetryPolicy = iota )
Click to show internal directories.
Click to hide internal directories.