完成client的构建

This commit is contained in:
2024-05-31 18:00:24 +08:00
parent 2be9c90b79
commit a0adefcc0c
7 changed files with 77 additions and 10 deletions

View File

@ -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
}