Documentation ¶
Index ¶
- func CommonResponse[RES any]() client.ResponseBodyCheck
- func CommonResponse2[RES any]() client.ResponseBodyCheck
- func DoGet[RES any](url string) (*RES, error)
- func GetSubData[RES ResponseInterface[T], T any](url string) (T, error)
- func OptionGet[RES ResponseInterface[T], T any](options ...client.Option) func(url string) (T, error)
- type Option
- type Request
- func (req *Request[RES]) AddHeader(k, v string) *Request[RES]
- func (req *Request[RES]) BasicAuth(authUser, authPass string)
- func (req *Request[RES]) CachedHeader(key string) *Request[RES]
- func (req *Request[RES]) Client(c *http.Client) *Request[RES]
- func (req *Request[RES]) ContentType(contentType client.ContentType) *Request[RES]
- func (req *Request[RES]) Context(ctx context.Context) *Request[RES]
- func (req *Request[RES]) DisableLog() *Request[RES]
- func (r *Request[RES]) Do(req any) (*RES, error)
- func (r *Request[RES]) Get(url string) (*RES, error)
- func (req *Request[RES]) Header(header client.Header) *Request[RES]
- func (req *Request[RES]) LogLevel(lvl client.LogLevel) *Request[RES]
- func (req *Request[RES]) Logger(logger client.AccessLog) *Request[RES]
- func (req *Request[RES]) Method(method string) *Request[RES]
- func (req *Request[RES]) Origin() *client.Request
- func (r *Request[RES]) Post(url string, param any) (*RES, error)
- func (req *Request[RES]) Proxy(url string) *Request[RES]
- func (req *Request[RES]) ResponseHandler(handler func(response *http.Response) (retry bool, data []byte, err error)) *Request[RES]
- func (req *Request[RES]) RetryHandler(handle func(*client.Request)) *Request[RES]
- func (req *Request[RES]) RetryTimes(retryTimes int) *Request[RES]
- func (req *Request[RES]) RetryTimesWithInterval(retryTimes int, retryInterval time.Duration) *Request[RES]
- func (req *Request[RES]) SetRequest(handle func(*client.Request)) *Request[RES]
- func (req *Request[RES]) Tag(tag string) *Request[RES]
- func (req *Request[RES]) Timeout(timeout time.Duration) *Request[RES]
- func (req *Request[RES]) Url(url string) *Request[RES]
- type ResponseBody
- type ResponseBody2
- type ResponseInterface
- type SubDataRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommonResponse ¶
func CommonResponse[RES any]() client.ResponseBodyCheck
func CommonResponse2 ¶
func CommonResponse2[RES any]() client.ResponseBodyCheck
func GetSubData ¶
func GetSubData[RES ResponseInterface[T], T any](url string) (T, error)
Types ¶
type Request ¶
Request ...
func NewGetRequest ¶ added in v1.7.8
func (*Request[RES]) CachedHeader ¶ added in v1.7.8
func (*Request[RES]) ContentType ¶
func (req *Request[RES]) ContentType(contentType client.ContentType) *Request[RES]
func (*Request[RES]) DisableLog ¶ added in v1.7.8
func (*Request[RES]) ResponseHandler ¶ added in v1.7.8
func (req *Request[RES]) ResponseHandler(handler func(response *http.Response) (retry bool, data []byte, err error)) *Request[RES]
handler 返回值:是否重试,返回数据,错误
func (*Request[RES]) RetryHandler ¶ added in v1.7.8
func (*Request[RES]) RetryTimes ¶ added in v1.7.8
func (*Request[RES]) RetryTimesWithInterval ¶ added in v1.7.8
func (*Request[RES]) SetRequest ¶ added in v1.7.8
type ResponseBody ¶
type ResponseBody[RES any] struct { Status int `json:"status"` Data RES `json:"data"` Message string `json:"message"` }
func (*ResponseBody[RES]) CheckError ¶
func (res *ResponseBody[RES]) CheckError() error
type ResponseBody2 ¶
type ResponseBody2[RES any] struct { Code int `json:"code"` Msg string `json:"msg"` Data RES `json:"data"` }
func (*ResponseBody2[RES]) CheckError ¶
func (res *ResponseBody2[RES]) CheckError() error
func (*ResponseBody2[RES]) GetData ¶
func (res *ResponseBody2[RES]) GetData() *RES
type ResponseInterface ¶
type ResponseInterface[T any] interface { client.ResponseBodyCheck GetData() T }
type SubDataRequest ¶
type SubDataRequest[RES ResponseInterface[T], T any] Request[RES]
一个语法糖,一般不用
func NewSubDataRequestParams ¶ added in v1.7.8
func NewSubDataRequestParams[RES ResponseInterface[T], T any](req *client.Request) *SubDataRequest[RES, T]
func (*SubDataRequest[RES, T]) Do ¶
func (r *SubDataRequest[RES, T]) Do(req any) (T, error)
Do create a HTTP request
func (*SubDataRequest[RES, T]) Get ¶ added in v1.7.8
func (req *SubDataRequest[RES, T]) Get(url string) (T, error)
func (*SubDataRequest[RES, T]) Origin ¶
func (req *SubDataRequest[RES, T]) Origin() *client.Request
Click to show internal directories.
Click to hide internal directories.