Documentation
¶
Index ¶
- func NewHttpClient(timeout time.Duration) *http.Client
- func NewHttpTransport() http.RoundTripper
- type Client
- func (c *Client) Create(method, url string, args ...any) Requester
- func (c *Client) Delete(url string, args ...any) Requester
- func (c *Client) Do(r *http.Request, out any) error
- func (c *Client) Get(url string, args ...any) Requester
- func (c *Client) Patch(url string, args ...any) Requester
- func (c *Client) Post(url string, args ...any) Requester
- func (c *Client) Put(url string, args ...any) Requester
- type Option
- type Requester
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHttpTransport ¶
func NewHttpTransport() http.RoundTripper
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func MustClient ¶
type Option ¶
type Option struct {
// 默认使用 http.DefaultClient
Client *http.Client
// 解析相应 **必须包含**
// 无需手动response.Body.Close() 会自动调用
// func(res *http.Response, out any) error {
// dec:=json.NewDecode(res.Body)
// return dec.Decode(out)
// }
ParseResponse func(*http.Response, any) error
// 修改请求
// 比如统一添加auth 或 签名认证等信息
ModfityRequest func(*http.Request)
// 基础url
BaseURL string
// 熔断器配置
BreakerSetting *gobreaker.Settings
}
Click to show internal directories.
Click to hide internal directories.