Documentation ¶
Index ¶
- Variables
- func Fetch(url string) (*http.Response, error)
- func Get(url string, opts ...Option) (*http.Response, error)
- func Post(url string, body io.Reader, opts ...Option) (*http.Response, error)
- func Request(method, url string, body io.Reader, opts ...Option) (*http.Response, error)
- func WithJSONBody(v any) io.Reader
- func WithURLEncodedBody(query map[string]string) io.Reader
- type Config
- type Context
- type Fetcher
- func (f *Fetcher) Fetch(url string) (resp *http.Response, err error)
- func (f *Fetcher) Get(url string, opts ...Option) (resp *http.Response, err error)
- func (f *Fetcher) Post(url string, body io.Reader, opts ...Option) (resp *http.Response, err error)
- func (f *Fetcher) Request(method, url string, body io.Reader, opts ...Option) (resp *http.Response, err error)
- type Option
- func WithAuthorization(token string) Option
- func WithBasicAuth(username, password string) Option
- func WithHeader(key, value string) Option
- func WithHeaders(headers map[string]string) Option
- func WithQuery(key, value string) Option
- func WithQueryMap(query map[string]string) Option
- func WithQueryPairs(kv ...string) Option
- func WithRaiseForStatus(v bool) Option
- func WithRandomUserAgent() Option
- func WithReferer(referer string) Option
- func WithRequest(fn func(req *http.Request)) Option
- func WithUserAgent(ua string) Option
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultFetcher = Default(&Config{RandomUserAgent: true})
Functions ¶
func WithJSONBody ¶
Types ¶
type Context ¶
type Context struct { Config // contains filtered or unexported fields }
Context is used for each request.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
type Option ¶
type Option func(*Context)
func WithAuthorization ¶
func WithBasicAuth ¶
func WithHeader ¶
func WithHeaders ¶
func WithQueryMap ¶
func WithQueryPairs ¶
func WithRaiseForStatus ¶
func WithRandomUserAgent ¶
func WithRandomUserAgent() Option
func WithReferer ¶
func WithRequest ¶
func WithUserAgent ¶
Click to show internal directories.
Click to hide internal directories.