aboutsummaryrefslogtreecommitdiff
path: root/sessions.go
diff options
context:
space:
mode:
Diffstat (limited to 'sessions.go')
-rw-r--r--sessions.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/sessions.go b/sessions.go
index ffdae5c..0a318ed 100644
--- a/sessions.go
+++ b/sessions.go
@@ -103,17 +103,14 @@ const registryKey = `webx:mw.sessions`
// GetRegistry returns a registry instance for the current request.
func GetRegistry(ctx echo.Context) *Registry {
- if v, ok := ctx.Internal().Load(registryKey); ok {
- registry, ok := v.(*Registry)
- if ok {
- return registry
- }
- }
registry := &Registry{
context: ctx,
sessions: make(map[string]sessionInfo),
}
- ctx.Internal().Store(registryKey, registry)
+ actual, loaded := ctx.Internal().LoadOrStore(registryKey, registry)
+ if loaded {
+ registry = actual.(*Registry)
+ }
return registry
}