Documentation
¶
Overview ¶
Package sdreq req库扩展
Index ¶
- Variables
- func GetForBytes(ctx context.Context, client *req.Client, url string, opts ...RequestOption) (int, []byte, error)
- func GetForJson[R any](ctx context.Context, client *req.Client, url string, opts ...RequestOption) (int, R, error)
- func GetForResponse(ctx context.Context, client *req.Client, url string, opts ...RequestOption) (*req.Response, error)
- func GetForText(ctx context.Context, client *req.Client, url string, opts ...RequestOption) (int, string, error)
- func New(opts *Options) *req.Client
- func PostForBytes(ctx context.Context, client *req.Client, url string, body any, ...) (int, []byte, error)
- func PostForJson[R any](ctx context.Context, client *req.Client, url string, body any, ...) (int, R, error)
- func PostForResponse(ctx context.Context, client *req.Client, url string, body any, ...) (*req.Response, error)
- func PostForText(ctx context.Context, client *req.Client, url string, body any, ...) (int, string, error)
- func ToQueryParam(v any) string
- func ToQueryParams(params map[string]any) map[string]string
- type Options
- type RequestOption
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultLogger req.Logger = logger{}
Functions ¶
func GetForBytes ¶
func GetForJson ¶
func GetForResponse ¶
func GetForResponse(ctx context.Context, client *req.Client, url string, opts ...RequestOption) (*req.Response, error)
func GetForText ¶
func PostForBytes ¶
func PostForJson ¶
func PostForResponse ¶
func PostForText ¶
func ToQueryParam ¶
Types ¶
type Options ¶
type Options struct { // common BaseUrl string UserAgent string Headers map[string]string QueryParams map[string]string PathParams map[string]string AuthUsername string AuthPassword string Cookies []*http.Cookie // cert Certs []tls.Certificate CertFilename string KeyFilename string // log/dump Log bool DebugLog bool DumpAll bool // timeout / retry TimeoutMS int64 // 超时时间,单位毫秒 RetryIntervalMS int64 RetryCount int }
type RequestOption ¶
type RequestOption func(*req.Request) *req.Request
func EnableDump ¶
func EnableDump() RequestOption
func Header ¶
func Header(k, v string) RequestOption
func Headers ¶
func Headers(headers map[string]string) RequestOption
func QueryParam ¶
func QueryParam(k string, v any) RequestOption
func QueryParams ¶
func QueryParams(params map[string]any) RequestOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.