📅  最后修改于: 2022-03-11 14:45:01.802000             🧑  作者: Mango
// Adding key:values into application/x-www-form-urlencoded type req
form := url.Values{}
form.Add("key1", "value1")
form.Add("key2", "value2")
form.Add("key3", "value3")
// Preparing HTTP Request
req, err := http.NewRequest("POST", HOST, strings.NewReader(form.Encode()))
if err != nil {
e.Logger.Info("Error: %v", err)
return err
}
// Setting Content Type
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// Sending HTTP request
respNew, err := http.DefaultClient.Do(req)
if err != nil {
e.Logger.Info("Error: %v", err)
return err
}