httpRequest

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiRequest

type ApiRequest struct {
	Url     string                 //请求的相对地址,如果BaseUri为空,就必须是绝对路径
	Params  map[string]interface{} //get,delete的Params参数
	BaseUri string                 //请求地址url的前缀
	Body    map[string]interface{}
	Header  map[string]interface{}
	Cookie  map[string]interface{}
	Method  string //请求的方法get,post,put,patch,delete,head等
	Proxy   string //请求设置的http_proxy代理

	//支持post,put,patch以json格式传递,[]int{1, 2, 3},map[string]string{"a":"b"}格式
	//也可以是json字符串
	Json interface{}
	FileField
}

func (*ApiRequest) Do

func (a *ApiRequest) Do() *Result

func (*ApiRequest) GetData

func (a *ApiRequest) GetData(resp *request.Response, err error) *Result

处理请求的结果

func (*ApiRequest) ParseData

func (a *ApiRequest) ParseData(d map[string]interface{}) map[string]string

func (*ApiRequest) SetFileName

func (a *ApiRequest) SetFileName(fileName string)

type ApiStdRes

type ApiStdRes struct {
	Code    int
	Message string
	Data    interface{}
}

标准的api返回格式

type FileField

type FileField struct {
	FieldName string //上传文件对应的表单file字段名
	File      string //上传文件名称,需要绝对路径
	FileName  string //上传后的文件名称
}

type Result

type Result struct {
	Err  error
	Body string
}

func (*Result) ParseJson

func (result *Result) ParseJson() (res *ApiStdRes, e error)

对返回的result.Body做json反序列化处理

Jump to

Keyboard shortcuts

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