Documentation
¶
Overview ¶
Package session provides thin helpers around gin-contrib/sessions.
Index ¶
- Constants
- Variables
- func Clear(c *gin.Context, hooks ...Hook) error
- func ClearWith(c *gin.Context, opts Options, hooks ...Hook) error
- func Delete(c *gin.Context, key string, hooks ...Hook) error
- func DeleteWith(c *gin.Context, key string, opts Options, hooks ...Hook) error
- func Get(c *gin.Context, key string) any
- func Middleware(cfg Config) (gin.HandlerFunc, error)
- func Register(value any)
- func Set(c *gin.Context, key string, value any, hooks ...Hook) error
- func SetWith(c *gin.Context, key string, value any, opts Options, hooks ...Hook) error
- type Config
- type Hook
- type Options
- type RedisConfig
- type Session
- type Store
Constants ¶
View Source
const ( TypeCookie = "cookie" TypeMemory = "memory" TypeRedis = "redis" DefaultKey = "sid" DefaultPath = "/" DefaultMaxAge = 30 * 60 )
Variables ¶
View Source
var ErrSecretRequired = errors.New("session: secret is required")
Functions ¶
func Middleware ¶
func Middleware(cfg Config) (gin.HandlerFunc, error)
Types ¶
type Config ¶
type Config struct {
Type string `mapstructure:"type" yaml:"type"`
Key string `mapstructure:"key" yaml:"key"`
Secret string `mapstructure:"secret" yaml:"secret"`
Path string `mapstructure:"path" yaml:"path"`
Domain string `mapstructure:"domain" yaml:"domain"`
MaxAge int `mapstructure:"max_age" yaml:"max_age"`
Secure bool `mapstructure:"secure" yaml:"secure"`
HTTPOnly bool `mapstructure:"http_only" yaml:"http_only"`
SameSite http.SameSite `mapstructure:"same_site" yaml:"same_site"`
Redis RedisConfig `mapstructure:"redis" yaml:"redis"`
}
type RedisConfig ¶
type RedisConfig struct {
Network string `mapstructure:"network" yaml:"network"`
Address string `mapstructure:"address" yaml:"address"`
Host string `mapstructure:"host" yaml:"host"`
Port int `mapstructure:"port" yaml:"port"`
Username string `mapstructure:"username" yaml:"username"`
Password string `mapstructure:"password" yaml:"password"`
DB int `mapstructure:"db" yaml:"db"`
PoolSize int `mapstructure:"pool_size" yaml:"pool_size"`
KeyPrefix string `mapstructure:"key_prefix" yaml:"key_prefix"`
}
Click to show internal directories.
Click to hide internal directories.