完成client的构建
This commit is contained in:
11
client.go
11
client.go
@ -19,14 +19,16 @@ import (
|
||||
//
|
||||
// Date : 15:27 2024/5/31
|
||||
func NewHttpClient(reqConfig *define.Request) (*HttpClient, error) {
|
||||
hc := &HttpClient{
|
||||
Client: NewRestyClient(reqConfig),
|
||||
reqConfig: reqConfig,
|
||||
}
|
||||
// 验证配置正确性以及初始化默认值
|
||||
if err := validate.RequestConfig(reqConfig); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
restyClient, restyRequest := NewRestyClient(reqConfig)
|
||||
hc := &HttpClient{
|
||||
Client: restyClient,
|
||||
request: restyRequest,
|
||||
reqConfig: reqConfig,
|
||||
}
|
||||
return hc, nil
|
||||
}
|
||||
|
||||
@ -37,6 +39,7 @@ func NewHttpClient(reqConfig *define.Request) (*HttpClient, error) {
|
||||
// Date : 15:27 2024/5/31
|
||||
type HttpClient struct {
|
||||
*resty.Client
|
||||
request *resty.Request
|
||||
reqConfig *define.Request
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user