Skip to content

Commit

Permalink
修复 redis session 断言的错误,以方便测试
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed May 29, 2024
1 parent 53f744f commit 6f3c1e3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion session/redis/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ func (rsp *SessionProvider) extractTokenString(ctx *ginx.Context) string {
// Get 返回 Session,如果没有拿到 session 或者 session 已经过期,会返回 error
func (rsp *SessionProvider) Get(ctx *gctx.Context) (session.Session, error) {
val, _ := ctx.Get(session.CtxSessionKey)
res, ok := val.(*Session)
// 对接口断言,而不是对实现断言
res, ok := val.(session.Session)
if ok {
return res, nil
}
Expand Down

0 comments on commit 6f3c1e3

Please sign in to comment.