Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated package to support go-session/session/v3 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yehuizhang
Copy link

Problem:

I am developing a new program using both go-session/session/v3 and go-session/gin-session and I noticed that when I call ginsession.New(session.SetSecure(false)), my IDE pops an error stating that go-session/session/v3.Option is not compatible with go-session/session.Option

Proposed solution

  • Upgrade package to use go module
  • Upgrade package to use go-session/session/v3
  • Upgrade package to use new version of Go

@coding-or-afk
Copy link

func Destroy(ctx *gin.Context) error {
	v, ok := ctx.Get(manageKey)
	if !ok {
		return fmt.Errorf("invalid session manager")
	}
	return v.(*session.Manager).Destroy(nil, ctx.Writer, ctx.Request)
}

// Refresh a session and return to session storage
func Refresh(ctx *gin.Context) (session.Store, error) {
	v, ok := ctx.Get(manageKey)
	if !ok {
		return nil, fmt.Errorf("invalid session manager")
	}
	return v.(*session.Manager).Refresh(nil, ctx.Writer, ctx.Request)
}

would be changed to ?

// Destroy a session
func Destroy(ctx *gin.Context) error {
	v, ok := ctx.Get(manageKey)
	if !ok {
		return fmt.Errorf("invalid session manager")
	}
	return v.(*session.Manager).Destroy(context.TODO(), ctx.Writer, ctx.Request)
}

// Refresh a session and return to session storage
func Refresh(ctx *gin.Context) (session.Store, error) {
	v, ok := ctx.Get(manageKey)
	if !ok {
		return nil, fmt.Errorf("invalid session manager")
	}
	return v.(*session.Manager).Refresh(context.TODO(), ctx.Writer, ctx.Request)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants