本文整理匯總了Golang中github.com/ursiform/bear.Context.Set方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Set方法的具體用法?Golang Context.Set怎麽用?Golang Context.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/ursiform/bear.Context
的用法示例。
在下文中一共展示了Context.Set方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: sessionDelIntercept
func (app *router) sessionDelIntercept(ctx *bear.Context) {
sessionID := ctx.Get(forest.SessionID).(string)
if sessionID == sessionIDWithSelfDestruct {
ctx.Set(forest.SessionID, nil)
}
if sessionID == sessionIDWithUserDestruct {
ctx.Set(forest.SessionUserID, nil)
}
ctx.Next()
}
示例2: sessionVerify
func (app *router) sessionVerify(ctx *bear.Context) {
_, ok := ctx.Get(forest.SessionID).(string)
if !ok {
ctx.Set(forest.Error, errors.New("sessionVerify failed"))
app.Ware("ServerError")(ctx)
return
} else {
ctx.Next()
}
}
示例3: Marshal
func (manager *sessionManager) Marshal(ctx *bear.Context) ([]byte, error) {
sessionID := ctx.Get(forest.SessionID).(string)
if sessionID == sessionIDWithMarshalError {
return nil, errors.New("manager.Marshal error")
}
if sessionID == sessionIDWithSelfDestruct {
ctx.Set(forest.SessionID, nil)
}
if sessionID == sessionIDWithUserDestruct {
ctx.Set(forest.SessionUserID, nil)
}
return []byte(sessionUserJSON), nil
}
示例4: Create
func (manager *sessionManager) Create(sessionID string, userID string,
userJSON string, ctx *bear.Context) error {
testError, ok := ctx.Get("testerror").(bool)
if !ok {
testError = false
}
if testError {
return errors.New("manager.Create error")
} else {
ctx.Set(forest.SessionID, sessionID)
ctx.Set(forest.SessionUserID, userID)
return nil
}
}
示例5: sessionCreateError
func (app *router) sessionCreateError(ctx *bear.Context) {
ctx.Set("testerror", true).Next()
}
示例6: initPostParse
func (app *router) initPostParse(ctx *bear.Context) {
ctx.Set(forest.Body, new(postBody)).Next()
}
示例7: customSafeErrorFilterSuccess
func (app *router) customSafeErrorFilterSuccess(ctx *bear.Context) {
ctx.Set(forest.Error, errors.New(customSafeErrorMessage))
app.Ware("ServerError")(ctx)
}
示例8: authenticate
func (app *router) authenticate(ctx *bear.Context) {
ctx.Set(forest.SessionID, sessionIDExistent)
ctx.Set(forest.SessionUserID, sessionUserID)
ctx.Next()
}
示例9: CreateEmpty
func (manager *sessionManager) CreateEmpty(sessionID string,
ctx *bear.Context) {
ctx.Set(forest.SessionID, sessionID)
}