Documentation
¶
Overview ¶
Package chttp (Cooked HTTP) provides a wrapper around http.Client with cookies, that are added to each request. It also allows to use custom Transport, which wraps the default transport and calls the user-defined function before and after the request.
Index ¶
- func CookiesToPtr(cookies []http.Cookie) []*http.Cookie
- func Must(cl *http.Client, err error) *http.Client
- func New(cookieDomain string, cookies []*http.Cookie, opts ...Option) (*http.Client, error)
- func NewWithTransport(cookieDomain string, cookies []*http.Cookie, rt http.RoundTripper) (*http.Client, error)
- type Option
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CookiesToPtr ¶ added in v1.1.0
CookiesToPtr is a convenience function that returns the slice with pointers to cookies.
func NewWithTransport ¶
func NewWithTransport(cookieDomain string, cookies []*http.Cookie, rt http.RoundTripper) (*http.Client, error)
NewWithTransport inits the HTTP client with cookies. It allows to use the custom Transport.
Types ¶
type Option ¶ added in v1.1.0
type Option func(*options)
func WithUserAgent ¶ added in v1.1.0
WithUserAgent allows to set the User-Agent on each request.
type Transport ¶
type Transport struct {
// BeforeReq is called before the request.
BeforeReq func(req *http.Request)
// AfterReq is called after the request.
AfterReq func(resp *http.Response, req *http.Request)
// contains filtered or unexported fields
}
Transport is a simple wrapper for http.RoundTripper to do something before and after RoundTrip.
func NewTransport ¶
func NewTransport(tr http.RoundTripper) *Transport
NewTransport returns a new Transport.
Click to show internal directories.
Click to hide internal directories.