本文整理匯總了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
}