當前位置: 首頁>>代碼示例>>Golang>>正文


Golang HTTPRequest.AddHeader方法代碼示例

本文整理匯總了Golang中github.com/mbanzon/simplehttp.HTTPRequest.AddHeader方法的典型用法代碼示例。如果您正苦於以下問題:Golang HTTPRequest.AddHeader方法的具體用法?Golang HTTPRequest.AddHeader怎麽用?Golang HTTPRequest.AddHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/mbanzon/simplehttp.HTTPRequest的用法示例。


在下文中一共展示了HTTPRequest.AddHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: makeRequest

// makeRequest shim performs a generic request, checking for a positive outcome.
// See simplehttp.MakeRequest for more details.
func makeRequest(r *simplehttp.HTTPRequest, kind string, p simplehttp.Payload) (*simplehttp.HTTPResponse, error) {
	r.AddHeader("User-Agent", MailgunGoUserAgent)
	rsp, err := r.MakeRequest(kind, p)
	if (err == nil) && notGood(rsp.Code, expected) {
		return rsp, newError(r.URL, expected, rsp.Code)
	}
	return rsp, err
}
開發者ID:9uuso,項目名稱:mailgun-go,代碼行數:10,代碼來源:rest_shim.go

示例2: makeDeleteRequest

// makeDeleteRequest shim performs a DELETE request, checking for a positive outcome.
// See simplehttp.MakeDeleteRequest for more details.
func makeDeleteRequest(r *simplehttp.HTTPRequest) (*simplehttp.HTTPResponse, error) {
	r.AddHeader("User-Agent", MailgunGoUserAgent)
	rsp, err := r.MakeDeleteRequest()
	if (err == nil) && notGood(rsp.Code, expected) {
		return rsp, newError(r.URL, expected, rsp.Code)
	}
	return rsp, err
}
開發者ID:9uuso,項目名稱:mailgun-go,代碼行數:10,代碼來源:rest_shim.go

示例3: 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)
}
開發者ID:9uuso,項目名稱:mailgun-go,代碼行數:13,代碼來源:rest_shim.go


注:本文中的github.com/mbanzon/simplehttp.HTTPRequest.AddHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。