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


Golang Request.Headers方法代碼示例

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


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

示例1: unmarshaler

func (e Endpoint) unmarshaler(req mercury.Request) tmsg.Unmarshaler {
	result := marshaling.Unmarshaler(req.Headers()[marshaling.ContentTypeHeader], e.Request)
	if result == nil { // Default to json
		result = marshaling.Unmarshaler(marshaling.JSONContentType, e.Request)
	}
	return result
}
開發者ID:mondough,項目名稱:mercury,代碼行數:7,代碼來源:endpoint.go

示例2: ProcessClientRequest

func (m requestTreeMiddleware) ProcessClientRequest(req mercury.Request) mercury.Request {
	if req.Headers()[parentIdHeader] == "" { // Don't overwrite an exiting header
		if parentId, ok := req.Context().Value(reqIdCtxKey).(string); ok && parentId != "" {
			req.SetHeader(parentIdHeader, parentId)
		}
	}

	// Pass through the current service and endpoint as the origin of this request
	req.SetHeader(originServiceHeader, CurrentServiceFor(req))
	req.SetHeader(originEndpointHeader, CurrentEndpointFor(req))

	return req
}
開發者ID:robmurtha,項目名稱:mercury,代碼行數:13,代碼來源:middleware.go

示例3: old2NewRequest

func old2NewRequest(oldReq mercury.Request) typhon.Request {
	ep := oldReq.Endpoint()
	if !strings.HasPrefix(ep, "/") {
		ep = "/" + ep
	}
	v := typhon.Request{
		Context: oldReq.Context(),
		Request: http.Request{
			Method: "POST",
			URL: &url.URL{
				Scheme: "http",
				Host:   oldReq.Service(),
				Path:   ep},
			Proto:         "HTTP/1.1",
			ProtoMajor:    1,
			ProtoMinor:    1,
			Header:        toHeader(oldReq.Headers()),
			Host:          oldReq.Service(),
			Body:          ioutil.NopCloser(bytes.NewReader(oldReq.Payload())),
			ContentLength: int64(len(oldReq.Payload()))}}
	v.Header.Set(legacyIdHeader, oldReq.Id())
	return v
}
開發者ID:mondough,項目名稱:mercury,代碼行數:23,代碼來源:message.go

示例4: ProcessServerRequest

func (m requestTreeMiddleware) ProcessServerRequest(req mercury.Request) (mercury.Request, mercury.Response) {
	req.SetContext(context.WithValue(req.Context(), reqIdCtxKey, req.Id()))
	if v := req.Headers()[parentIdHeader]; v != "" {
		req.SetContext(context.WithValue(req.Context(), parentIdCtxKey, v))
	}

	// Set the current service and endpoint into the context
	req.SetContext(context.WithValue(req.Context(), currentServiceHeader, req.Service()))
	req.SetContext(context.WithValue(req.Context(), currentEndpointHeader, req.Endpoint()))

	// Set the originator into the context
	req.SetContext(context.WithValue(req.Context(), originServiceHeader, req.Headers()[originServiceHeader]))
	req.SetContext(context.WithValue(req.Context(), originEndpointHeader, req.Headers()[originEndpointHeader]))

	return req, nil
}
開發者ID:robmurtha,項目名稱:mercury,代碼行數:16,代碼來源:middleware.go

示例5: unmarshaler

func (e Endpoint) unmarshaler(req mercury.Request) tmsg.Unmarshaler {
	return marshaling.Unmarshaler(req.Headers()[marshaling.ContentTypeHeader], e.Request)
}
開發者ID:robmurtha,項目名稱:mercury,代碼行數:3,代碼來源:endpoint.go


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