diff options
Diffstat (limited to 'sessions.go')
-rw-r--r-- | sessions.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sessions.go b/sessions.go index db4a57b..147889e 100644 --- a/sessions.go +++ b/sessions.go @@ -107,12 +107,17 @@ type sessionInfo struct { const registryKey = `webx:mw.sessions` // GetRegistry returns a registry instance for the current request. -func GetRegistry(ctx echo.Context) *Registry { - registry := &Registry{ +func GetRegistry(ctx echo.Context) (registry *Registry) { + actual, loaded := ctx.Internal().Load(registryKey) + if loaded { + registry = actual.(*Registry) + return + } + registry = &Registry{ context: ctx, sessions: make(map[string]sessionInfo), } - actual, loaded := ctx.Internal().LoadOrStore(registryKey, registry) + actual, loaded = ctx.Internal().LoadOrStore(registryKey, registry) if loaded { registry = actual.(*Registry) } |