Documentation ¶
Index ¶
- type Options
- type Request
- func (r *Request) Delete(uri string, opts ...Options) (*Response, error)
- func (r *Request) Get(uri string, opts ...Options) (*Response, error)
- func (r *Request) Options(uri string, opts ...Options) (*Response, error)
- func (r *Request) Patch(uri string, opts ...Options) (*Response, error)
- func (r *Request) Post(uri string, opts ...Options) (*Response, error)
- func (r *Request) Put(uri string, opts ...Options) (*Response, error)
- func (r *Request) Request(method, uri string, opts ...Options) (*Response, error)
- type Response
- func (r *Response) GetBody() (ResponseBody, error)
- func (r *Response) GetHeader(name string) []string
- func (r *Response) GetHeaderLine(name string) string
- func (r *Response) GetHeaders() map[string][]string
- func (r *Response) GetParsedBody() (*gjson.Result, error)
- func (r *Response) GetReasonPhrase() string
- func (r *Response) GetRequest() *http.Request
- func (r *Response) GetResponse() *http.Response
- func (r *Response) GetStatusCode() int
- func (r *Response) HasHeader(name string) bool
- func (r *Response) IsTimeout() bool
- type ResponseBody
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { Debug bool NoInsecureSkipVerify bool NoDisableKeepAlives bool BaseURI string Timeout float32 Query interface{} Headers map[string]interface{} Cookies interface{} FormParams map[string]interface{} ByteData []byte // Add By Teval: multipart/form-data; FormData map[string]any JSON interface{} XML interface{} Proxy string ParseBodyFunc func(src []byte) (dist []byte) // 自定义响应数据解密 // contains filtered or unexported fields }
Options object
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request object
func (*Request) Post ¶
Post send post request
Example ¶
f, _ := os.Open("./111.png") defer f.Close() r, err := Post("http://localhost:8021/upload", Options{ Debug: true, FormData: map[string]interface{}{ "xfile": "", }, }) fmt.Println(r, err)
Output:
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response response object
func (*Response) GetBody ¶
func (r *Response) GetBody() (ResponseBody, error)
GetBody parse response body
func (*Response) GetHeaderLine ¶
GetHeaderLine get a single response header
func (*Response) GetHeaders ¶
GetHeaders get response headers
func (*Response) GetParsedBody ¶
GetParsedBody parse response body with gjson
func (*Response) GetReasonPhrase ¶
GetReasonPhrase get response reason phrase
func (*Response) GetRequest ¶
GetRequest get request object
func (*Response) GetResponse ¶ added in v1.2.4
GetResponse get response object - By Teval 20231128
func (*Response) GetStatusCode ¶
GetStatusCode get response status code
type ResponseBody ¶
type ResponseBody []byte
ResponseBody response body
func (ResponseBody) GetContents ¶
func (r ResponseBody) GetContents() string
GetContents format response body as string
func (ResponseBody) Read ¶
func (r ResponseBody) Read(length int) []byte
Read get slice of response body
Click to show internal directories.
Click to hide internal directories.