本文整理汇总了Golang中github.com/mbanzon/simplehttp.HTTPRequest.MakePostRequest方法的典型用法代码示例。如果您正苦于以下问题:Golang HTTPRequest.MakePostRequest方法的具体用法?Golang HTTPRequest.MakePostRequest怎么用?Golang HTTPRequest.MakePostRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mbanzon/simplehttp.HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest.MakePostRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: makePostRequest
// makePostRequest shim performs a POST request, checking for a positive outcome.
// See simplehttp.MakePostRequest for more details.
func makePostRequest(r *simplehttp.HTTPRequest, p simplehttp.Payload) (*simplehttp.HTTPResponse, error) {
r.AddHeader("User-Agent", MailgunGoUserAgent)
rsp, err := r.MakePostRequest(p)
if (err == nil) && notGood(rsp.Code, expected) {
return rsp, newError(r.URL, expected, rsp.Code)
}
return rsp, err
}
示例2: postResponseFromJSON
// postResponseFromJSON shim performs a POST request, checking for a positive outcome.
// See simplehttp.PostResponseFromJSON for more details.
func postResponseFromJSON(r *simplehttp.HTTPRequest, p simplehttp.Payload, v interface{}) error {
r.AddHeader("User-Agent", MailgunGoUserAgent)
response, err := r.MakePostRequest(p)
if err != nil {
return err
}
if notGood(response.Code, expected) {
return newError(r.URL, expected, response.Code)
}
return response.ParseFromJSON(v)
}