summaryrefslogtreecommitdiff
path: root/sessions.go
diff options
context:
space:
mode:
authorshen_wen_hui <shenwenhui@zuzuche.com>2019-05-05 13:04:16 +0300
committershen_wen_hui <shenwenhui@zuzuche.com>2019-05-05 13:04:16 +0300
commit820298e67e38f60df55ebdd80fd8a2b29027beca (patch)
treeaff20878e802b6ca4c04b2a4103e014621c15ab4 /sessions.go
parentf83061d6d718ca255de55f64f92fc53203f68d33 (diff)
update
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
}