yeeHttp

package
v0.0.0-...-89bd919 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(url, filename string) (size int64, err error)

Download 下载文件

Types

type RequestWrapper

type RequestWrapper struct {
	// contains filtered or unexported fields
}

RequestWrapper 对http请求的封装

func Get

func Get(url string) *RequestWrapper

Get 初始化get请求

func NewNewRequestWithHttpReq

func NewNewRequestWithHttpReq(req *http.Request) *RequestWrapper

func NewRequest

func NewRequest(method, url string) *RequestWrapper

NewRequest 初始化请求

func Post

func Post(url string) *RequestWrapper

Post 初始化post请求

func (*RequestWrapper) AddHeader

func (r *RequestWrapper) AddHeader(key, value string) *RequestWrapper

func (*RequestWrapper) Exec

func (r *RequestWrapper) Exec() *RequestWrapper

Exec 执行http请求

func (*RequestWrapper) Json

func (r *RequestWrapper) Json(data string) *RequestWrapper

Json 设置post请求的参数 body主体 `{"greeting":"hello world"}`

func (*RequestWrapper) Param

func (r *RequestWrapper) Param(key, value string) *RequestWrapper

Param 添加url参数

func (*RequestWrapper) Pipe

func (r *RequestWrapper) Pipe(w io.Writer) (written int64, err error)

Pipe 结果输出为io.Writer 返回length 以及error

func (*RequestWrapper) Query

func (r *RequestWrapper) Query(query string) *RequestWrapper

func (*RequestWrapper) Response

func (r *RequestWrapper) Response() (*http.Response, error)

返回response

func (*RequestWrapper) SetHeader

func (r *RequestWrapper) SetHeader(key, value string) *RequestWrapper

SetHeader 设置header

func (*RequestWrapper) SkipVerify

func (r *RequestWrapper) SkipVerify() *RequestWrapper

SkipVerify 忽略tls认证

func (*RequestWrapper) ToBytes

func (r *RequestWrapper) ToBytes() ([]byte, error)

ToBytes 结果输出为[]byte

func (*RequestWrapper) ToFile

func (r *RequestWrapper) ToFile(filename string) (size int64, err error)

ToFile 结果输出到文件

func (*RequestWrapper) ToString

func (r *RequestWrapper) ToString() (string, error)

ToString 结果输出为string

func (*RequestWrapper) UseClient

func (r *RequestWrapper) UseClient(client *http.Client) *RequestWrapper

UseClient 设置client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL