本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}