session

package
v1.25.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultConfig is the default Recover middleware config.
	DefaultConfig = Config{
		ErrorHandleFunc: func(ctx *gin.Context, err error) {
			ctx.AbortWithStatusJSON(http.StatusInternalServerError, models.Error(500, err.Error()))
		},
		StoreKey:  "github.com/go-session/gin-session/store",
		ManageKey: "github.com/go-session/gin-session/manage",
		Skipper: func(_ *gin.Context) bool {
			return false
		},
	}
)

Functions

func Destroy

func Destroy(ctx *gin.Context) error

Destroy a session

func FromContext

func FromContext(ctx *gin.Context) session.Store

FromContext Get session storage from context

func New

func New(opt ...session.Option) gin.HandlerFunc

New create a session middleware

func NewWithConfig

func NewWithConfig(config Config, opt ...session.Option) gin.HandlerFunc

NewWithConfig create a session middleware

func Refresh

func Refresh(ctx *gin.Context) (session.Store, error)

Refresh a session and return to session storage

Types

type Config

type Config struct {
	// error handling when starting the session
	ErrorHandleFunc ErrorHandleFunc
	// keys stored in the context
	StoreKey string
	// keys stored in the context
	ManageKey string
	// defines a function to skip middleware.Returning true skips processing
	// the middleware.
	Skipper func(*gin.Context) bool
}

Config defines the config for Session middleware

type ErrorHandleFunc

type ErrorHandleFunc func(*gin.Context, error)

ErrorHandleFunc error handling function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL