client

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestHeaderKeyXQiniuDate = "X-Qiniu-Date"
)

Variables

View Source
var DebugMode = false

用来打印调试信息

View Source
var DeepDebugInfo = false
View Source
var DefaultClient = Client{&http.Client{Transport: http.DefaultTransport}}
View Source
var UserAgent = getUserAgentWithAppName("default")

Functions

func CallRet

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

func DecodeJsonFromReader

func DecodeJsonFromReader(reader io.Reader, v interface{}) error

func ResponseError

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

Types

type Client

type Client struct {
	*http.Client
}

func (Client) Call

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

func (Client) CallWithBodyGetter

func (r Client) CallWithBodyGetter(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header, body io.Reader,
	getBody func() (io.ReadCloser, error), bodyLength int64) (err error)

func (Client) CredentialedCall

func (r Client) CredentialedCall(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header) error

func (Client) Do

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

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)

func (Client) DoRequestWithBodyGetter

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

type ErrorInfo

type ErrorInfo struct {
	Err   string `json:"error,omitempty"`
	Key   string `json:"key,omitempty"`
	Reqid string `json:"reqid,omitempty"`
	Errno int    `json:"errno,omitempty"`
	Code  int    `json:"code"`
}

func (*ErrorInfo) Error

func (r *ErrorInfo) Error() string

func (*ErrorInfo) ErrorDetail

func (r *ErrorInfo) ErrorDetail() string

func (*ErrorInfo) HttpCode

func (r *ErrorInfo) HttpCode() int

func (*ErrorInfo) RpcError

func (r *ErrorInfo) RpcError() (code, errno int, key, err string)

Jump to

Keyboard shortcuts

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