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


Golang Request.UnderlyingRequest方法代碼示例

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


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

示例1: IsAuthorized

func (p *UpdateContactRequestHandler) IsAuthorized(req wm.Request, cxt wm.Context) (bool, string, wm.Request, wm.Context, int, error) {
	ucc := cxt.(UpdateContactContext)
	hasSignature, userId, _, err := apiutil.CheckSignature(p.authDS, req.UnderlyingRequest())
	if !hasSignature || err != nil {
		return hasSignature, "dsocial", req, cxt, http.StatusUnauthorized, err
	}
	if userId != "" {
		user, _ := p.ds.RetrieveUserAccountById(userId)
		ucc.SetAuthUser(user)
	}
	return userId != "", "", req, cxt, 0, nil
}
開發者ID:pomack,項目名稱:dsocial.go,代碼行數:12,代碼來源:update.go

示例2: IsAuthorized

func (p *LogoutAccountRequestHandler) IsAuthorized(req wm.Request, cxt wm.Context) (bool, string, wm.Request, wm.Context, int, error) {
	lac := cxt.(LogoutAccountContext)
	hasSignature, userId, _, err := apiutil.CheckSignature(p.authDS, req.UnderlyingRequest())
	if !hasSignature || err != nil {
		return hasSignature, "dsocial", req, cxt, http.StatusUnauthorized, err
	}
	accessKey, _ := apiutil.RetrieveAccessKeyFromRequest(p.authDS, req.UnderlyingRequest())
	lac.SetAccessKey(accessKey)
	if userId != "" {
		user, _ := p.ds.RetrieveUserAccountById(userId)
		lac.SetUser(user)
	}
	return true, "", req, cxt, 0, nil
}
開發者ID:pomack,項目名稱:dsocial.go,代碼行數:14,代碼來源:logout.go

示例3: IsAuthorized

func (p *ViewAccountRequestHandler) IsAuthorized(req wm.Request, cxt wm.Context) (bool, string, wm.Request, wm.Context, int, error) {
	vac := cxt.(ViewAccountContext)
	hasSignature, userId, consumerId, err := apiutil.CheckSignature(p.authDS, req.UnderlyingRequest())
	if !hasSignature || err != nil {
		return hasSignature, "dsocial", req, cxt, http.StatusUnauthorized, err
	}
	if userId != "" {
		user, _ := p.ds.RetrieveUserAccountById(userId)
		vac.SetRequestingUser(user)
	}
	if consumerId != "" {
		consumer, _ := p.ds.RetrieveConsumerAccountById(consumerId)
		vac.SetRequestingConsumer(consumer)
	}
	return true, "", req, cxt, 0, nil
}
開發者ID:pomack,項目名稱:dsocial.go,代碼行數:16,代碼來源:view.go

示例4: IsAuthorized

func (p *GeneratePrivateKeyRequestHandler) IsAuthorized(req wm.Request, cxt wm.Context) (bool, string, wm.Request, wm.Context, int, error) {
	gpkc := cxt.(GeneratePrivateKeyContext)
	hasSignature, userId, consumerId, err := apiutil.CheckSignature(p.authDS, req.UnderlyingRequest())
	if !hasSignature || err != nil {
		return hasSignature, "dsocial", req, cxt, http.StatusUnauthorized, err
	}
	if userId != "" {
		user, _ := p.ds.RetrieveUserAccountById(userId)
		gpkc.SetUser(user)
	}
	if consumerId != "" {
		consumer, _ := p.ds.RetrieveConsumerAccountById(consumerId)
		gpkc.SetConsumer(consumer)
	}
	if (userId != "" && gpkc.User() == nil) || (consumerId != "" && gpkc.Consumer() == nil) {
		gpkc.SetUser(nil)
		gpkc.SetConsumer(nil)
	}
	return true, "", req, cxt, 0, nil
}
開發者ID:pomack,項目名稱:dsocial.go,代碼行數:20,代碼來源:generate_private_key.go

示例5: Forbidden

func (p *CreateAccountRequestHandler) Forbidden(req wm.Request, cxt wm.Context) (bool, wm.Request, wm.Context, int, os.Error) {
	cac := cxt.(CreateAccountContext)
	hasSignature, userId, consumerId, err := apiutil.CheckSignature(p.authDS, req.UnderlyingRequest())
	if err != nil {
		return true, req, cxt, 403, err
	}
	if hasSignature {
		if userId != "" {
			user, _ := p.ds.RetrieveUserAccountById(userId)
			cac.SetRequestingUser(user)
		}
		if consumerId != "" {
			consumer, _ := p.ds.RetrieveConsumerAccountById(consumerId)
			cac.SetRequestingConsumer(consumer)
		}
		if (userId != "" && (cac.RequestingUser() == nil || !cac.RequestingUser().Accessible())) && (consumerId != "" && (cac.RequestingConsumer() == nil || !cac.RequestingConsumer().Accessible())) {
			// Cannot find user or consumer with specified id
			return true, req, cxt, 0, nil
		}
	}
	return false, req, cxt, 0, nil
}
開發者ID:pombredanne,項目名稱:dsocial.go,代碼行數:22,代碼來源:create.go


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