client

package
v0.0.0-...-59ebc2b Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugMode = true

DebugMode 用来打印调试信息

View Source
var DeepDebugInfo = true

DeepDebugInfo 深度打印

View Source
var DefaultClient = Client{&http.Client{Transport: http.DefaultTransport}}

DefaultClient Default client

View Source
var UserAgent = "Golang danghongyun/client package"

UserAgent agent

Functions

func CallRet

func CallRet(ctx context.Context, ret interface{}, resp *http.Response) (err error)

CallRet 返回对象转换

func ResponseError

func ResponseError(resp *http.Response) (err error)

ResponseError 返回错误

func TurnOnDebug

func TurnOnDebug()

TurnOnDebug 开启Debug模式

Types

type Client

type Client struct {
	*http.Client
}

Client 负责发送HTTP请求到七牛接口服务器

func (Client) Call

func (r Client) Call(ctx context.Context, ret interface{}, method, reqURL string, headers http.Header) (err error)

Call get call

func (Client) CallWithForm

func (r Client) CallWithForm(ctx context.Context, ret interface{}, method, reqURL string, headers http.Header,
	param map[string][]string) (err error)

CallWithForm do requeset

func (Client) CallWithJSON

func (r Client) CallWithJSON(ctx context.Context, ret interface{}, method, reqURL string, headers http.Header,
	param interface{}) (err error)

CallWithJSON api call

func (Client) CallWithJSONQuery

func (r Client) CallWithJSONQuery(ctx context.Context, ret interface{}, method, reqURL string, headers http.Header,
	param map[string][]string) (err error)

CallWithJSONQuery api call

func (Client) Do

func (r Client) Do(ctx context.Context, req *http.Request) (resp *http.Response, err error)

Do do

func (Client) DoRequest

func (r Client) DoRequest(ctx context.Context, method, reqURL string, headers http.Header) (resp *http.Response, err error)

DoRequest do request

func (Client) DoRequestQueryWithJSON

func (r Client) DoRequestQueryWithJSON(ctx context.Context, method, reqURL string, headers http.Header,
	data map[string][]string) (resp *http.Response, err error)

DoRequestQueryWithJSON request

func (Client) DoRequestWith

func (r Client) DoRequestWith(ctx context.Context, method, reqURL string, headers http.Header, body io.Reader,
	bodyLength int) (resp *http.Response, err error)

DoRequestWith request

func (Client) DoRequestWith64

func (r Client) DoRequestWith64(ctx context.Context, method, reqURL string, headers http.Header, body io.Reader,
	bodyLength int64) (resp *http.Response, err error)

DoRequestWith64 request

func (Client) DoRequestWithForm

func (r Client) DoRequestWithForm(ctx context.Context, method, reqURL string, headers http.Header,
	data map[string][]string) (resp *http.Response, err error)

DoRequestWithForm request

func (Client) DoRequestWithJSON

func (r Client) DoRequestWithJSON(ctx context.Context, method, reqURL string, headers http.Header,
	data interface{}) (resp *http.Response, err error)

DoRequestWithJSON request

type ErrorInfo

type ErrorInfo struct {
	HTTPCode int    `json:"http_code"` //http code
	Code     int    `json:"code"`      // 整型错误码,0成功,其它值失败
	Message  string `json:"message"`   // 字符串,可能包含错误或者别的一些信息
	Result   string `json:"result"`    // 字符串,返回的结果
	Success  bool   `json:"success"`   // true 或 false

}

ErrorInfo errorinfo

func (*ErrorInfo) Error

func (r *ErrorInfo) Error() string

Error error

func (*ErrorInfo) ErrorDetail

func (r *ErrorInfo) ErrorDetail() string

ErrorDetail error

Jump to

Keyboard shortcuts

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