Documentation
¶
Index ¶
- func HttpGet[T any](ser IService, path string, sets ...Set) (res T, body []byte, err error)
- func HttpJsonToObj[T any](bs []byte) (res T, err error)
- func HttpPost[T any](ser IService, path string, in any, sets ...Set) (res T, body []byte, err error)
- func ReadResponse(resp *http.Response) (res []byte, err error)
- func ResponseToObj[T any](resp *http.Response) (res T, bs []byte, err error)
- type Config
- type ConnProxy
- type DataResponse
- type IService
- type Info
- type Request
- type Response
- type Service
- func (this_ *Service) Close()
- func (this_ *Service) DataReader(data any) (res io.Reader, err error)
- func (this_ *Service) Get(path string, sets ...Set) (res []byte, err error)
- func (this_ *Service) GetRequest(url string, sets ...Set) (resp *http.Response, err error)
- func (this_ *Service) GetUrl(path string) (res string)
- func (this_ *Service) Info() (res *Info, err error)
- func (this_ *Service) Post(path string, data any, sets ...Set) (res []byte, err error)
- func (this_ *Service) PostRequest(url string, body io.Reader, sets ...Set) (resp *http.Response, err error)
- func (this_ *Service) Request(method, url string, body io.Reader, sets ...Set) (resp *http.Response, err error)
- type Set
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HttpJsonToObj ¶
Types ¶
type Config ¶
type Config struct {
// Disabled 禁用 上层 初始化服务时候 可以判断该属性 如果为 配置 true 则不去初始化服务
Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"`
RootUrl string `json:"rootUrl" yaml:"rootUrl"`
// 超时时间 单位 毫秒
Timeout int `json:"timeout" yaml:"timeout"`
MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"`
MaxConnsPerHost int `json:"maxConnsPerHost" yaml:"maxConnsPerHost"`
// 超时时间 单位 毫秒
IdleConnTimeout int `json:"idleConnTimeout" yaml:"idleConnTimeout"`
Tls *TLSConfig `json:"tls,omitempty" yaml:"tls,omitempty"`
// contains filtered or unexported fields
}
func (*Config) GetConnProxy ¶
func (*Config) SetConnProxy ¶
type DataResponse ¶
type DataResponse[T any] struct { Code string `json:"code"` Msg string `json:"msg"` Data T `json:"data"` }
func HttpPostDataResponse ¶
type IService ¶
type IService interface {
// Close 关闭 客户端
Close()
// Info 查看 zk 相关信息
Info() (info *Info, err error)
Request(method, url string, body io.Reader, sets ...Set) (resp *http.Response, err error)
GetRequest(url string, sets ...Set) (resp *http.Response, err error)
PostRequest(url string, body io.Reader, sets ...Set) (resp *http.Response, err error)
GetUrl(path string) (res string)
Get(path string, sets ...Set) (res []byte, err error)
Post(path string, data any, sets ...Set) (res []byte, err error)
}
type Service ¶
type Service struct {
*Config
// contains filtered or unexported fields
}
func (*Service) GetRequest ¶
func (*Service) PostRequest ¶
Click to show internal directories.
Click to hide internal directories.