httpx

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProgressRead

func ProgressRead(r io.Reader, total int64, progress ...ProgressFunc) io.Reader

Types

type JSONObject

type JSONObject = fastjson.Object

type JSONValue

type JSONValue = fastjson.Value

type ProcessFunc

type ProcessFunc = func(resp *http.Response) error

func Process

func Process(process ProcessFunc) ProcessFunc

Process 处理下载流

func ProcessBytes

func ProcessBytes(process func(data []byte) error) ProcessFunc

ProcessBytes 以字节方式处理下载流

func ProcessCSV

func ProcessCSV(read func(reader *csv.Reader) error, skip ...int) ProcessFunc

func ProcessJSON

func ProcessJSON(v interface{}) ProcessFunc

ProcessJSON 以JSON格式映射下载流到结构指针

func ProcessJSONDocument

func ProcessJSONDocument(process func(jv *JSONValue) error) ProcessFunc

ProcessJSONDocument 以JSON格式处理下载流

func ProcessProgress

func ProcessProgress(read ReadFunc, progress ...ProgressFunc) ProcessFunc

ProcessProgress 带进度处理下载流

func ProcessTSV

func ProcessTSV(read func(reader *csv.Reader) error, skip ...int) ProcessFunc

func Read

func Read(readFn ReadFunc) ProcessFunc

Read 处理下载流

type ProgressFunc

type ProgressFunc = func(cur, total, pct int64)

type ReadFunc

type ReadFunc = func(r io.Reader) error

type X

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

X http 请求封装

func Get

func Get(url string) *X

Get Get

func New

func New() *X

New 创建一个请求对象

func Post

func Post(url string, body io.Reader) *X

Post Post

func (*X) Client

func (x *X) Client(cli *http.Client) *X

Client 客户端对象

func (*X) Debug

func (x *X) Debug(yes ...bool) *X

Debug 调试模式

func (*X) Do

func (x *X) Do() error

Do 执行请求和处理

func (*X) Err

func (x *X) Err() error

Err 请求和处理过程的错误信息

func (*X) Exec

func (x *X) Exec(ctx context.Context) error

Exec 执行请求和处理

func (*X) Process

func (x *X) Process(pFn ProcessFunc) *X

Process 处理函数

func (*X) Request

func (x *X) Request(method string, url string, body io.Reader) *X

Request 设置请求

func (*X) SetRequest

func (x *X) SetRequest(req *http.Request) *X

SetRequest 请求对象

Jump to

Keyboard shortcuts

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