client_generic

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonResponse

func CommonResponse[RES any]() client.ResponseBodyCheck

func CommonResponse2 added in v1.1.0

func CommonResponse2[RES any]() client.ResponseBodyCheck

func CustomizeGet

func CustomizeGet[RES ResponseInterface[T], T any](option client.Option) func(url string) (T, error)

Deprecated

func GetSubData

func GetSubData[RES ResponseInterface[T], T any](url string) (T, error)

func SimpleGet

func SimpleGet[RES any](url string) (*RES, error)

Types

type Option added in v1.1.0

type Option[RES any] func(req *Request[RES]) *Request[RES]

type Request added in v1.1.0

type Request[RES any] client.Request

Request ...

func New added in v1.1.0

func New[RES any]() *Request[RES]

func NewByRequest added in v1.1.0

func NewByRequest[RES any](req *client.Request) *Request[RES]

func NewGetRequest

func NewGetRequest[RES any](url string) *Request[RES]

func NewRequest

func NewRequest[RES any](url string, method string) *Request[RES]

func (*Request[RES]) AddHeader added in v1.1.0

func (req *Request[RES]) AddHeader(k, v string) *Request[RES]

func (*Request[RES]) CachedHeader added in v1.1.0

func (req *Request[RES]) CachedHeader(key string) *Request[RES]

func (*Request[RES]) ContentType added in v1.1.0

func (req *Request[RES]) ContentType(contentType client.ContentType) *Request[RES]

func (*Request[RES]) DisableLog added in v1.1.0

func (req *Request[RES]) DisableLog() *Request[RES]

func (*Request[RES]) Do added in v1.1.0

func (r *Request[RES]) Do(req any) (*RES, error)

Do create a HTTP request

func (*Request[RES]) Get added in v1.1.0

func (r *Request[RES]) Get(url string) (*RES, error)

func (*Request[RES]) LogLevel added in v1.3.0

func (req *Request[RES]) LogLevel(lvl client.LogLevel) *Request[RES]

func (*Request[RES]) Method added in v1.1.0

func (req *Request[RES]) Method(method string) *Request[RES]

func (*Request[RES]) Origin added in v1.1.0

func (req *Request[RES]) Origin() *client.Request

func (*Request[RES]) Post added in v1.1.0

func (r *Request[RES]) Post(url string, param any) (*RES, error)

func (*Request[RES]) ResponseHandler added in v1.1.0

func (req *Request[RES]) ResponseHandler(handler func([]byte) ([]byte, error)) *Request[RES]

func (*Request[RES]) RetryHandler added in v1.1.0

func (req *Request[RES]) RetryHandler(handle func(*client.Request)) *Request[RES]

func (*Request[RES]) RetryTimes added in v1.1.0

func (req *Request[RES]) RetryTimes(retryTimes int) *Request[RES]

func (*Request[RES]) SetHeader added in v1.1.0

func (req *Request[RES]) SetHeader(header client.Header) *Request[RES]

func (*Request[RES]) SetProxy added in v1.1.0

func (req *Request[RES]) SetProxy(url string) *Request[RES]

func (*Request[RES]) SetRequest added in v1.1.0

func (req *Request[RES]) SetRequest(handle func(*client.Request)) *Request[RES]

func (*Request[RES]) Timeout added in v1.1.0

func (req *Request[RES]) Timeout(timeout time.Duration) *Request[RES]

func (*Request[RES]) Url added in v1.1.0

func (req *Request[RES]) Url(url string) *Request[RES]

func (*Request[RES]) WithClient added in v1.1.0

func (req *Request[RES]) WithClient(c *http.Client) *Request[RES]

func (*Request[RES]) WithLogger added in v1.1.0

func (req *Request[RES]) WithLogger(logger client.LogCallback) *Request[RES]

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 added in v1.1.0

type ResponseBody2[RES any] struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data RES    `json:"data"`
}

func (*ResponseBody2[RES]) CheckError added in v1.1.0

func (res *ResponseBody2[RES]) CheckError() error

func (*ResponseBody2[RES]) GetData added in v1.1.0

func (res *ResponseBody2[RES]) GetData() *RES

type ResponseInterface added in v1.1.0

type ResponseInterface[T any] interface {
	client.ResponseBodyCheck
	GetData() T
}

type SubDataRequest

type SubDataRequest[RES ResponseInterface[T], T any] Request[RES]

一个语法糖,一般不用

func NewSubDataRequestParams

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

func (req *SubDataRequest[RES, T]) Get(url string) (T, error)

func (*SubDataRequest[RES, T]) Origin

func (req *SubDataRequest[RES, T]) Origin() *client.Request

Jump to

Keyboard shortcuts

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