Documentation ¶
Index ¶
Constants ¶
View Source
const ( CUrlencoded = "application/x-www-form-urlencoded" CJson = "application/json" CFormData = "application/form-data" MethodGet = "GET" MethodPost = "POST" MethodPut = "PUT" MethodDelete = "DELETE" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Response ¶
type Response struct { Status string // e.g. "200 OK" StatusCode int // e.g. 200 // Header 将标头键映射到值。如果响应具有具有相同键的多个标头,则可以使用逗号分隔符将它们连接起来。 //(RFC 7230 第 3.2.2 节要求多个标头在语义上等效于逗号分隔的序列。 // 当标头值被此结构中的其他字段(例如,ContentLength、TransferEncoding、Trailer)复制时,字段值是权威的。 // // 映射中的键是规范化的(请参阅 CanonicalHeaderKey) Header http.Header Body []byte Cookies []*http.Cookie }
Response 请求结果
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session http.client 简单功能封装
func NewSession ¶
NewSession 创建 Session 对象。可以自定义请求头
func (*Session) Do ¶
Do 发送请求
method: 请求方法 MethodGet , MethodPost , MethodPut , MethodDelete params: GET请求参数,可选 字符串(string)/ 键值对(map[string]any)/ nil 例:a=5&b=6&c="acc" / map[string]any{ "a":5, "b":6, "c":"acc" } data: 用于提交 x-www-form-urlencoded 数据, 可选 string / []byte / map[string]any / io.Reader / nil _json: 用于提交 json 数据, 可选 string / []byte / map[string]any / io.Reader / nil
Click to show internal directories.
Click to hide internal directories.