feat: add cookie-based session support using alexedwards/scs (#1)

- Add Session wrapper with typed getters (GetString, GetInt, GetBool, etc.)
- Add flash message support via Pop methods (PopString, PopInt, etc.)
- Add session utilities: Exists, Keys, ID, Clear, Destroy, RenewToken
- Create default session manager in New() for zero-config usage
- Allow custom session manager via Options.SessionManager
- Wrap mux with scs LoadAndSave middleware in Start()
- Add session example demonstrating login/logout with flash messages
This commit is contained in:
ryanhamamura
2026-01-09 06:59:26 -10:00
committed by GitHub
parent 43495ccada
commit 9a23188973
7 changed files with 284 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
package via
import "github.com/alexedwards/scs/v2"
type LogLevel int
const (
@@ -30,4 +32,9 @@ type Options struct {
// Plugins to extend the capabilities of the `Via` application.
Plugins []Plugin
// SessionManager enables cookie-based sessions. If set, Via wraps handlers
// with scs LoadAndSave middleware. Configure the session manager before
// passing it (lifetime, cookie settings, store, etc).
SessionManager *scs.SessionManager
}