Documentation ¶
Index ¶
- func ClientFromContext(ctx context.Context) (*http.Client, bool)
- func DisableKeepAlivesClient() *http.Client
- func DisableKeepAlivesTransport() *http.Transport
- func NewContextWithClient(ctx context.Context, cli *http.Client) context.Context
- func NewContextWithRequest(ctx context.Context, req *http.Request) context.Context
- func NewContextWithResponse(ctx context.Context, resp *http.Response) context.Context
- func PooledClient() *http.Client
- func PooledTransport() *http.Transport
- func RequestFromContext(ctx context.Context) (*http.Request, bool)
- func ResponseFromContext(ctx context.Context) (*http.Response, bool)
- type ClientBuilder
- func (builder *ClientBuilder) Build() *http.Client
- func (builder *ClientBuilder) CheckRedirect(f func(req *http.Request, via []*http.Request) error) *ClientBuilder
- func (builder *ClientBuilder) Jar(jar http.CookieJar) *ClientBuilder
- func (builder *ClientBuilder) Timeout(timeout time.Duration) *ClientBuilder
- func (builder *ClientBuilder) Transport(transport http.RoundTripper) *ClientBuilder
- type CompositeHandler
- type DoCommand
- type FormData
- type RequestBuilder
- func (builder *RequestBuilder) APIKey(key string, value string) *RequestBuilder
- func (builder *RequestBuilder) AddCookie(cookie *http.Cookie) *RequestBuilder
- func (builder *RequestBuilder) AddHeader(name, value string) *RequestBuilder
- func (builder *RequestBuilder) AddQuery(key, value string) *RequestBuilder
- func (builder *RequestBuilder) BasicAuth(username, password string) *RequestBuilder
- func (builder *RequestBuilder) BearerAuth(token string) *RequestBuilder
- func (builder *RequestBuilder) Body(body io.Reader, contentType string) *RequestBuilder
- func (builder *RequestBuilder) Build(ctx context.Context) (*http.Request, error)
- func (builder *RequestBuilder) BytesBody(body []byte, contentType string) *RequestBuilder
- func (builder *RequestBuilder) CacheControl(directives ...string) *RequestBuilder
- func (builder *RequestBuilder) Connect() *RequestBuilder
- func (builder *RequestBuilder) Cookie(cookie *http.Cookie) *RequestBuilder
- func (builder *RequestBuilder) Cookies(cookies ...*http.Cookie) *RequestBuilder
- func (builder *RequestBuilder) CustomAuth(scheme, token string) *RequestBuilder
- func (builder *RequestBuilder) Delete() *RequestBuilder
- func (builder *RequestBuilder) Execute(ctx context.Context, cli *http.Client) *ResponseHelper
- func (builder *RequestBuilder) FormBody(form url.Values) *RequestBuilder
- func (builder *RequestBuilder) Get() *RequestBuilder
- func (builder *RequestBuilder) GobBody(body any) *RequestBuilder
- func (builder *RequestBuilder) Head() *RequestBuilder
- func (builder *RequestBuilder) Header(name, value string) *RequestBuilder
- func (builder *RequestBuilder) Headers(header http.Header) *RequestBuilder
- func (builder *RequestBuilder) IfMatch(etags ...string) *RequestBuilder
- func (builder *RequestBuilder) IfModifiedSince(time string) *RequestBuilder
- func (builder *RequestBuilder) IfNoneMatch(etag string) *RequestBuilder
- func (builder *RequestBuilder) IfUnmodifiedSince(time string) *RequestBuilder
- func (builder *RequestBuilder) JSONBody(body any) *RequestBuilder
- func (builder *RequestBuilder) Method(method string) *RequestBuilder
- func (builder *RequestBuilder) MultipartBody(formData ...*FormData) *RequestBuilder
- func (builder *RequestBuilder) ObjectBody(body any, marshal func(any) ([]byte, error), contentType string) *RequestBuilder
- func (builder *RequestBuilder) Options() *RequestBuilder
- func (builder *RequestBuilder) Patch() *RequestBuilder
- func (builder *RequestBuilder) Post() *RequestBuilder
- func (builder *RequestBuilder) ProtobufBody(body proto.Message) *RequestBuilder
- func (builder *RequestBuilder) Put() *RequestBuilder
- func (builder *RequestBuilder) Queries(queries url.Values) *RequestBuilder
- func (builder *RequestBuilder) Query(name, value string) *RequestBuilder
- func (builder *RequestBuilder) QueryString(q string) *RequestBuilder
- func (builder *RequestBuilder) RemoveCookie(cookie *http.Cookie) *RequestBuilder
- func (builder *RequestBuilder) RemoveHeader(name string) *RequestBuilder
- func (builder *RequestBuilder) RemoveQuery(name string) *RequestBuilder
- func (builder *RequestBuilder) TextBody(body string, contentType string) *RequestBuilder
- func (builder *RequestBuilder) Trace() *RequestBuilder
- func (builder *RequestBuilder) URL(uri *url.URL) *RequestBuilder
- func (builder *RequestBuilder) URLString(urlString string) *RequestBuilder
- func (builder *RequestBuilder) UserAgent(ua string) *RequestBuilder
- func (builder *RequestBuilder) XMLBody(body any) *RequestBuilder
- type ResponseHelper
- func (helper *ResponseHelper) Body() (io.ReadCloser, error)
- func (helper *ResponseHelper) BytesBody() ([]byte, error)
- func (helper *ResponseHelper) Cookies() ([]*http.Cookie, error)
- func (helper *ResponseHelper) Err() error
- func (helper *ResponseHelper) FileBody(file io.Writer) error
- func (helper *ResponseHelper) GobBody(body proto.Message) error
- func (helper *ResponseHelper) Headers() (http.Header, error)
- func (helper *ResponseHelper) JSONBody(body any) error
- func (helper *ResponseHelper) ObjectBody(body any, unmarshal func([]byte, any) error) error
- func (helper *ResponseHelper) ProtobufBody(body proto.Message) error
- func (helper *ResponseHelper) StatusCode() (int, error)
- func (helper *ResponseHelper) TextBody() (string, error)
- func (helper *ResponseHelper) Trailer() (http.Header, error)
- func (helper *ResponseHelper) XMLBody(body any) error
- type TransportBuilder
- func (builder *TransportBuilder) Build() *http.Transport
- func (builder *TransportBuilder) Dial(dial func(ctx context.Context, network string, addr string) (net.Conn, error)) *TransportBuilder
- func (builder *TransportBuilder) DialTLS(...) *TransportBuilder
- func (builder *TransportBuilder) DisableCompression(disable bool) *TransportBuilder
- func (builder *TransportBuilder) DisableKeepAlives(disable bool) *TransportBuilder
- func (builder *TransportBuilder) ExpectContinueTimeout(timeout time.Duration) *TransportBuilder
- func (builder *TransportBuilder) ForceAttemptHTTP2(enable bool) *TransportBuilder
- func (builder *TransportBuilder) GetProxyConnectHeader(...) *TransportBuilder
- func (builder *TransportBuilder) IdleConnTimeout(timeout time.Duration) *TransportBuilder
- func (builder *TransportBuilder) MaxConnsPerHost(n int) *TransportBuilder
- func (builder *TransportBuilder) MaxIdleConns(n int) *TransportBuilder
- func (builder *TransportBuilder) MaxIdleConnsPerHost(n int) *TransportBuilder
- func (builder *TransportBuilder) MaxResponseHeaderBytes(n int64) *TransportBuilder
- func (builder *TransportBuilder) Proxy(proxy func(*http.Request) (*url.URL, error)) *TransportBuilder
- func (builder *TransportBuilder) ProxyConnectHeader(h http.Header) *TransportBuilder
- func (builder *TransportBuilder) ReadBufferSize(n int) *TransportBuilder
- func (builder *TransportBuilder) ResponseHeaderTimeout(timeout time.Duration) *TransportBuilder
- func (builder *TransportBuilder) TLSConfig(tlsConfig *tls.Config) *TransportBuilder
- func (builder *TransportBuilder) TLSHandshakeTimeout(timeout time.Duration) *TransportBuilder
- func (builder *TransportBuilder) TLSNextProto(f map[string]func(authority string, c *tls.Conn) http.RoundTripper) *TransportBuilder
- func (builder *TransportBuilder) WriteBufferSize(n int) *TransportBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableKeepAlivesClient ¶
DisableKeepAlivesClient returns a new http.Client with similar default values to http.Client, but with a non-shared Transport, idle connections disabled, and keepalives disabled.
func DisableKeepAlivesTransport ¶
DisableKeepAlivesTransport returns a new http.Transport with similar default values to http.DefaultTransport, but with idle connections and keepalives disabled.
func NewContextWithClient ¶
func NewContextWithRequest ¶
func NewContextWithResponse ¶
func PooledClient ¶
PooledClient returns a new http.Client with similar default values to http.Client, but with a shared Transport. Do not use this function for transient clients as it can leak file descriptors over time. Only use this for clients that will be re-used for the same host(s).
func PooledTransport ¶
PooledTransport 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).
Types ¶
type ClientBuilder ¶
type ClientBuilder struct {
// contains filtered or unexported fields
}
func (*ClientBuilder) Build ¶
func (builder *ClientBuilder) Build() *http.Client
func (*ClientBuilder) CheckRedirect ¶
func (builder *ClientBuilder) CheckRedirect(f func(req *http.Request, via []*http.Request) error) *ClientBuilder
func (*ClientBuilder) Jar ¶
func (builder *ClientBuilder) Jar(jar http.CookieJar) *ClientBuilder
func (*ClientBuilder) Timeout ¶
func (builder *ClientBuilder) Timeout(timeout time.Duration) *ClientBuilder
func (*ClientBuilder) Transport ¶
func (builder *ClientBuilder) Transport(transport http.RoundTripper) *ClientBuilder
type CompositeHandler ¶ added in v1.1.0
type CompositeHandler struct {
// contains filtered or unexported fields
}
func (*CompositeHandler) AddHandler ¶ added in v1.1.0
func (*CompositeHandler) ServeHTTP ¶ added in v1.1.0
func (h *CompositeHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)
type RequestBuilder ¶
type RequestBuilder struct {
// contains filtered or unexported fields
}
func NewRequestBuilder ¶ added in v1.0.7
func NewRequestBuilder() *RequestBuilder
func (*RequestBuilder) APIKey ¶
func (builder *RequestBuilder) APIKey(key string, value string) *RequestBuilder
func (*RequestBuilder) AddCookie ¶
func (builder *RequestBuilder) AddCookie(cookie *http.Cookie) *RequestBuilder
func (*RequestBuilder) AddHeader ¶
func (builder *RequestBuilder) AddHeader(name, value string) *RequestBuilder
func (*RequestBuilder) AddQuery ¶
func (builder *RequestBuilder) AddQuery(key, value string) *RequestBuilder
func (*RequestBuilder) BasicAuth ¶
func (builder *RequestBuilder) BasicAuth(username, password string) *RequestBuilder
func (*RequestBuilder) BearerAuth ¶
func (builder *RequestBuilder) BearerAuth(token string) *RequestBuilder
func (*RequestBuilder) Body ¶
func (builder *RequestBuilder) Body(body io.Reader, contentType string) *RequestBuilder
func (*RequestBuilder) BytesBody ¶
func (builder *RequestBuilder) BytesBody(body []byte, contentType string) *RequestBuilder
func (*RequestBuilder) CacheControl ¶
func (builder *RequestBuilder) CacheControl(directives ...string) *RequestBuilder
func (*RequestBuilder) Connect ¶
func (builder *RequestBuilder) Connect() *RequestBuilder
func (*RequestBuilder) Cookie ¶
func (builder *RequestBuilder) Cookie(cookie *http.Cookie) *RequestBuilder
func (*RequestBuilder) Cookies ¶
func (builder *RequestBuilder) Cookies(cookies ...*http.Cookie) *RequestBuilder
func (*RequestBuilder) CustomAuth ¶
func (builder *RequestBuilder) CustomAuth(scheme, token string) *RequestBuilder
func (*RequestBuilder) Delete ¶
func (builder *RequestBuilder) Delete() *RequestBuilder
func (*RequestBuilder) Execute ¶ added in v1.0.6
func (builder *RequestBuilder) Execute(ctx context.Context, cli *http.Client) *ResponseHelper
func (*RequestBuilder) FormBody ¶
func (builder *RequestBuilder) FormBody(form url.Values) *RequestBuilder
func (*RequestBuilder) Get ¶
func (builder *RequestBuilder) Get() *RequestBuilder
func (*RequestBuilder) GobBody ¶
func (builder *RequestBuilder) GobBody(body any) *RequestBuilder
func (*RequestBuilder) Head ¶
func (builder *RequestBuilder) Head() *RequestBuilder
func (*RequestBuilder) Header ¶
func (builder *RequestBuilder) Header(name, value string) *RequestBuilder
func (*RequestBuilder) Headers ¶
func (builder *RequestBuilder) Headers(header http.Header) *RequestBuilder
func (*RequestBuilder) IfMatch ¶
func (builder *RequestBuilder) IfMatch(etags ...string) *RequestBuilder
func (*RequestBuilder) IfModifiedSince ¶
func (builder *RequestBuilder) IfModifiedSince(time string) *RequestBuilder
func (*RequestBuilder) IfNoneMatch ¶
func (builder *RequestBuilder) IfNoneMatch(etag string) *RequestBuilder
func (*RequestBuilder) IfUnmodifiedSince ¶
func (builder *RequestBuilder) IfUnmodifiedSince(time string) *RequestBuilder
func (*RequestBuilder) JSONBody ¶
func (builder *RequestBuilder) JSONBody(body any) *RequestBuilder
func (*RequestBuilder) Method ¶
func (builder *RequestBuilder) Method(method string) *RequestBuilder
func (*RequestBuilder) MultipartBody ¶
func (builder *RequestBuilder) MultipartBody(formData ...*FormData) *RequestBuilder
func (*RequestBuilder) ObjectBody ¶
func (builder *RequestBuilder) ObjectBody(body any, marshal func(any) ([]byte, error), contentType string) *RequestBuilder
func (*RequestBuilder) Options ¶
func (builder *RequestBuilder) Options() *RequestBuilder
func (*RequestBuilder) Patch ¶
func (builder *RequestBuilder) Patch() *RequestBuilder
func (*RequestBuilder) Post ¶
func (builder *RequestBuilder) Post() *RequestBuilder
func (*RequestBuilder) ProtobufBody ¶
func (builder *RequestBuilder) ProtobufBody(body proto.Message) *RequestBuilder
func (*RequestBuilder) Put ¶
func (builder *RequestBuilder) Put() *RequestBuilder
func (*RequestBuilder) Queries ¶
func (builder *RequestBuilder) Queries(queries url.Values) *RequestBuilder
func (*RequestBuilder) Query ¶
func (builder *RequestBuilder) Query(name, value string) *RequestBuilder
func (*RequestBuilder) QueryString ¶
func (builder *RequestBuilder) QueryString(q string) *RequestBuilder
func (*RequestBuilder) RemoveCookie ¶
func (builder *RequestBuilder) RemoveCookie(cookie *http.Cookie) *RequestBuilder
func (*RequestBuilder) RemoveHeader ¶
func (builder *RequestBuilder) RemoveHeader(name string) *RequestBuilder
func (*RequestBuilder) RemoveQuery ¶
func (builder *RequestBuilder) RemoveQuery(name string) *RequestBuilder
func (*RequestBuilder) TextBody ¶
func (builder *RequestBuilder) TextBody(body string, contentType string) *RequestBuilder
func (*RequestBuilder) Trace ¶
func (builder *RequestBuilder) Trace() *RequestBuilder
func (*RequestBuilder) URL ¶
func (builder *RequestBuilder) URL(uri *url.URL) *RequestBuilder
func (*RequestBuilder) URLString ¶
func (builder *RequestBuilder) URLString(urlString string) *RequestBuilder
func (*RequestBuilder) UserAgent ¶
func (builder *RequestBuilder) UserAgent(ua string) *RequestBuilder
func (*RequestBuilder) XMLBody ¶
func (builder *RequestBuilder) XMLBody(body any) *RequestBuilder
type ResponseHelper ¶
type ResponseHelper struct {
// contains filtered or unexported fields
}
func NewResponseHelper ¶ added in v1.0.3
func NewResponseHelper(resp *http.Response, err error) *ResponseHelper
func (*ResponseHelper) Body ¶
func (helper *ResponseHelper) Body() (io.ReadCloser, error)
func (*ResponseHelper) BytesBody ¶
func (helper *ResponseHelper) BytesBody() ([]byte, error)
func (*ResponseHelper) Err ¶ added in v1.0.3
func (helper *ResponseHelper) Err() error
func (*ResponseHelper) JSONBody ¶
func (helper *ResponseHelper) JSONBody(body any) error
func (*ResponseHelper) ObjectBody ¶
func (*ResponseHelper) ProtobufBody ¶
func (helper *ResponseHelper) ProtobufBody(body proto.Message) error
func (*ResponseHelper) StatusCode ¶
func (helper *ResponseHelper) StatusCode() (int, error)
func (*ResponseHelper) TextBody ¶
func (helper *ResponseHelper) TextBody() (string, error)
func (*ResponseHelper) XMLBody ¶
func (helper *ResponseHelper) XMLBody(body any) error
type TransportBuilder ¶
type TransportBuilder struct {
// contains filtered or unexported fields
}
func (*TransportBuilder) Build ¶
func (builder *TransportBuilder) Build() *http.Transport
func (*TransportBuilder) Dial ¶
func (builder *TransportBuilder) Dial(dial func(ctx context.Context, network string, addr string) (net.Conn, error)) *TransportBuilder
func (*TransportBuilder) DialTLS ¶
func (builder *TransportBuilder) DialTLS(dialTLS func(ctx context.Context, network string, addr string) (net.Conn, error)) *TransportBuilder
func (*TransportBuilder) DisableCompression ¶
func (builder *TransportBuilder) DisableCompression(disable bool) *TransportBuilder
func (*TransportBuilder) DisableKeepAlives ¶
func (builder *TransportBuilder) DisableKeepAlives(disable bool) *TransportBuilder
func (*TransportBuilder) ExpectContinueTimeout ¶
func (builder *TransportBuilder) ExpectContinueTimeout(timeout time.Duration) *TransportBuilder
func (*TransportBuilder) ForceAttemptHTTP2 ¶
func (builder *TransportBuilder) ForceAttemptHTTP2(enable bool) *TransportBuilder
func (*TransportBuilder) GetProxyConnectHeader ¶
func (builder *TransportBuilder) GetProxyConnectHeader(f func(ctx context.Context, proxyURL *url.URL, target string) (http.Header, error)) *TransportBuilder
func (*TransportBuilder) IdleConnTimeout ¶
func (builder *TransportBuilder) IdleConnTimeout(timeout time.Duration) *TransportBuilder
func (*TransportBuilder) MaxConnsPerHost ¶
func (builder *TransportBuilder) MaxConnsPerHost(n int) *TransportBuilder
func (*TransportBuilder) MaxIdleConns ¶
func (builder *TransportBuilder) MaxIdleConns(n int) *TransportBuilder
func (*TransportBuilder) MaxIdleConnsPerHost ¶
func (builder *TransportBuilder) MaxIdleConnsPerHost(n int) *TransportBuilder
func (*TransportBuilder) MaxResponseHeaderBytes ¶
func (builder *TransportBuilder) MaxResponseHeaderBytes(n int64) *TransportBuilder
func (*TransportBuilder) Proxy ¶
func (builder *TransportBuilder) Proxy(proxy func(*http.Request) (*url.URL, error)) *TransportBuilder
func (*TransportBuilder) ProxyConnectHeader ¶
func (builder *TransportBuilder) ProxyConnectHeader(h http.Header) *TransportBuilder
func (*TransportBuilder) ReadBufferSize ¶
func (builder *TransportBuilder) ReadBufferSize(n int) *TransportBuilder
func (*TransportBuilder) ResponseHeaderTimeout ¶
func (builder *TransportBuilder) ResponseHeaderTimeout(timeout time.Duration) *TransportBuilder
func (*TransportBuilder) TLSConfig ¶
func (builder *TransportBuilder) TLSConfig(tlsConfig *tls.Config) *TransportBuilder
func (*TransportBuilder) TLSHandshakeTimeout ¶
func (builder *TransportBuilder) TLSHandshakeTimeout(timeout time.Duration) *TransportBuilder
func (*TransportBuilder) TLSNextProto ¶
func (builder *TransportBuilder) TLSNextProto(f map[string]func(authority string, c *tls.Conn) http.RoundTripper) *TransportBuilder
func (*TransportBuilder) WriteBufferSize ¶
func (builder *TransportBuilder) WriteBufferSize(n int) *TransportBuilder