当前位置: 首页>>代码示例>>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;未经允许,请勿转载。