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