gin_sessions

package module
v0.0.0-...-47e3142 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 3 Imported by: 0

README

Gin-Sessions

This is a simple session middleware for Gin

Why not use something that already exists you ask? Because I wanted to learn how to write a middleware for Gin + Existing libraries where confusing to me.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStorage

type InMemoryStorage struct {
	// contains filtered or unexported fields
}

func NewInMemoryStorage

func NewInMemoryStorage() *InMemoryStorage

func (*InMemoryStorage) Clear

func (s *InMemoryStorage) Clear()

func (*InMemoryStorage) Delete

func (s *InMemoryStorage) Delete(key string)

func (*InMemoryStorage) Get

func (s *InMemoryStorage) Get(session *Session)

func (*InMemoryStorage) Set

func (s *InMemoryStorage) Set(session Session) error

type Session

type Session struct {
	Cookie        string
	UserID        string
	Authenticated bool
}

type Sessions

type Sessions struct {
	Storage storage
	Name    string
	HashKey string
	MaxAge  int
}

func NewMiddleware

func NewMiddleware(storage storage, name string, hashKey string, maxAge int) *Sessions

func (*Sessions) Clear

func (s *Sessions) Clear()

func (*Sessions) DeleteSession

func (s *Sessions) DeleteSession(c *gin.Context)

func (*Sessions) GetSession

func (s *Sessions) GetSession(c *gin.Context) Session

func (*Sessions) Middleware

func (s *Sessions) Middleware() gin.HandlerFunc

func (*Sessions) NewSession

func (s *Sessions) NewSession(c *gin.Context, userID string)

Jump to

Keyboard shortcuts

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