Documentation ¶
Index ¶
- type Cli
- func (c *Cli) Client() *http.Client
- func (c *Cli) DoRequest(ctx context.Context, method, u string, header http.Header, body []byte) (*http.Response, []byte, error)
- func (c *Cli) DumpTransaction(req *http.Request, resp *http.Response, reqBody, respBody []byte, tryNum int)
- func (c *Cli) Get(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
- func (c *Cli) GetExtIPAddrInfo(ctx context.Context) (string, error)
- func (c *Cli) GetFile(ctx context.Context, u string, args url.Values, header http.Header, ...) (string, error)
- func (c *Cli) GetJSON(ctx context.Context, u string, args url.Values, header http.Header, ...) error
- func (c *Cli) GetQueryDoc(ctx context.Context, u string, args url.Values, header http.Header) (*goquery.Document, error)
- func (c *Cli) Post(ctx context.Context, u string, header http.Header, body []byte) ([]byte, error)
- func (c *Cli) PostForm(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
- func (c *Cli) PostFormParseJSON(ctx context.Context, u string, args url.Values, header http.Header, ...) error
- func (c *Cli) PostJSON(ctx context.Context, u string, header http.Header, data interface{}) ([]byte, error)
- func (c *Cli) PostJSONParseJSON(ctx context.Context, u string, data interface{}, header http.Header, ...) error
- func (c *Cli) Reset() error
- func (c *Cli) SetErrorHandler(fn ErrorHandler)
- type ErrorHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cli ¶
type Cli struct {
// contains filtered or unexported fields
}
Cli is a HTTP client
func (*Cli) DoRequest ¶
func (c *Cli) DoRequest( ctx context.Context, method, u string, header http.Header, body []byte, ) (*http.Response, []byte, error)
DoRequest performs an HTTP request
func (*Cli) DumpTransaction ¶
func (c *Cli) DumpTransaction( req *http.Request, resp *http.Response, reqBody, respBody []byte, tryNum int, )
DumpTransaction dumps an HTTP transaction content into a file
func (*Cli) Get ¶
func (c *Cli) Get(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
Get perform a GET request
func (*Cli) GetExtIPAddrInfo ¶
GetExtIPAddrInfo returns information about client's external IP address
func (*Cli) GetFile ¶
func (c *Cli) GetFile(ctx context.Context, u string, args url.Values, header http.Header, fPath string) (string, error)
GetFile gets a file and stores it on the disk.
If fPath doesn't contain an extension, it will be added automatically. In case of success file extension returned
func (*Cli) GetJSON ¶
func (c *Cli) GetJSON(ctx context.Context, u string, args url.Values, header http.Header, target interface{}) error
GetJSON performs a GET HTTP request and parses the response into a JSON
func (*Cli) GetQueryDoc ¶
func (c *Cli) GetQueryDoc(ctx context.Context, u string, args url.Values, header http.Header) (*goquery.Document, error)
GetQueryDoc performs a GET request and transform response into a goquery document
func (*Cli) PostForm ¶
func (c *Cli) PostForm(ctx context.Context, u string, args url.Values, header http.Header) ([]byte, error)
PostForm posts a form
func (*Cli) PostFormParseJSON ¶
func (c *Cli) PostFormParseJSON(ctx context.Context, u string, args url.Values, header http.Header, target interface{}) error
PostFormParseJSON performs a POST request and parses JSON response
func (*Cli) PostJSON ¶
func (c *Cli) PostJSON(ctx context.Context, u string, header http.Header, data interface{}) ([]byte, error)
PostJSON posts a JSON request
func (*Cli) PostJSONParseJSON ¶
func (c *Cli) PostJSONParseJSON(ctx context.Context, u string, data interface{}, header http.Header, target interface{}) error
PostJSONParseJSON performs a POST request having JSON body and parses JSON response
func (*Cli) SetErrorHandler ¶
func (c *Cli) SetErrorHandler(fn ErrorHandler)
SetErrorHandler sets HTTP request error handler