Documentation ¶
Index ¶
- func AddHeader(h *http.Header, name, value string) error
- func CopyHTTPRequest(r *http.Request, body io.ReadCloser) *http.Request
- func DelHeader(h *http.Header, name string) error
- func FromJSON(req interface{}, r *http.Request) (body []byte, err error)
- func GetCookieValue(cookies, name string) (ret string)
- func GetRemoteAddr(r *http.Request) string
- func HeaderToArray(header http.Header) (res []string)
- func ToJSON(i interface{}, w io.Writer) error
- type Client
- func (c *Client) GetByte(ctx context.Context, method, url string, body io.Reader, opts ...HeaderOpion) (*Response, error)
- func (c *Client) GetClient() *http.Client
- func (c *Client) Request(ctx context.Context, method, url string, body io.Reader, opts ...HeaderOpion) (*http.Response, error)
- func (c *Client) WithClient(cl *http.Client)
- type HeaderOpion
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyHTTPRequest ¶
CopyHTTPRequest 用于复制新的HTTP Request
CopyHTTPRequest(req, ioutil.NopCloser(&bytes.Buffer{}))
func GetCookieValue ¶
GetCookieValue 获取指定名称的cookie
func GetRemoteAddr ¶
func HeaderToArray ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetByte ¶
func (c *Client) GetByte(ctx context.Context, method, url string, body io.Reader, opts ...HeaderOpion) (*Response, error)
GetByte 相当于http.get()
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, method, url string, body io.Reader, opts ...HeaderOpion) (*http.Response, error)
method 参数: http.MethodGet http.MethodPost 等, 如为非标准的访问请求会被报400
func (*Client) WithClient ¶
type HeaderOpion ¶
Click to show internal directories.
Click to hide internal directories.