summaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
Diffstat (limited to 'session.go')
-rw-r--r--session.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/session.go b/session.go
index 3718623..680f648 100644
--- a/session.go
+++ b/session.go
@@ -11,10 +11,11 @@ import (
"github.com/gorilla/sessions"
)
+type sessionContextKey struct{}
+
const (
- sessionCookie = "sessionKeks"
- sessionContextKey = "_session"
- dataKey = "data"
+ sessionCookie = "sessionKeks"
+ dataKey = "data"
)
func init() {
@@ -48,7 +49,7 @@ func (s *Session) Invalidate() {
}
func session(r *http.Request) Session {
- s := r.Context().Value(sessionContextKey).(*sessions.Session)
+ s := r.Context().Value(sessionContextKey{}).(*sessions.Session)
s.Options.HttpOnly = true
sd, ok := s.Values[dataKey].(SessionData)
@@ -72,7 +73,7 @@ func sessionHandler(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session, _ := sessionStore.Get(r, sessionCookie)
- ctx := context.WithValue(r.Context(), sessionContextKey, session)
+ ctx := context.WithValue(r.Context(), sessionContextKey{}, session)
next.ServeHTTP(w, r.WithContext(ctx))
})
}