增加配置定义

This commit is contained in:
白茶清欢 2022-05-02 15:03:56 +08:00
parent e82dc1353d
commit 55e9974c25
1 changed files with 18 additions and 5 deletions

View File

@ -11,6 +11,8 @@
// Date: 2022/05/01 19:56:48
package curl
import "net/http"
const (
// ContentTypeFormData form-data 请求
ContentTypeFormData = "form-data"
@ -49,6 +51,17 @@ type ApiRequestConfig struct {
CommonHeader map[string]string `json:"common_header"` // 全部请求都要传的header
Body []byte `json:"-"` // 请求体
FullURL string `json:"full_url"` // 完整请求地址
Timeout Timeout `json:"timeout"` // 超时配置
}
// Timeout 超时配置
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:02 2022/5/2
type Timeout struct {
Connect int64 `json:"connect"` // 连接超时
Read int64 `json:"read"` // 读取超时时间
}
// ApiResponse 接口响应结果
@ -59,9 +72,9 @@ type ApiRequestConfig struct {
//
// Date: 2022/05/01 20:25:39
type ApiResponse struct {
RequestConfig *ApiRequestConfig `json:"request_config"` // 请求配置
HttpCode int `json:"http_code"` // http状态码
Body []byte `json:"body"` // 响应体
BodyType string `json:"body_type"` // 响应体数据类型
Exception *Exception `json:"exception"` // 异常信息
RequestConfig *ApiRequestConfig `json:"request_config"` // 请求配置
Response *http.Response `json:"response"` // 响应体
Exception *Exception `json:"exception"` // 异常信息
StartRequestTime int64 `json:"start_request_time"` // 开始请求时间, 纳秒
FinishRequestTime int64 `json:"finish_request_time"` // 完成请求时间,纳秒
}