From 43ff70ebcff1674fba9aff126178f93076b32718 Mon Sep 17 00:00:00 2001 From: Jonathan Gillham Date: Mon, 21 Oct 2013 13:35:37 +0100 Subject: Proposed change to Registry.Get function when CookieStore.New produces an error. --- sessions.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sessions.go b/sessions.go index 53111b3..72b6ecb 100644 --- a/sessions.go +++ b/sessions.go @@ -144,7 +144,9 @@ func (s *Registry) Get(store Store, name string) (session *Session, err error) { if info, ok := s.sessions[name]; ok { session, err = info.s, info.e } else { - session, err = store.New(s.request, name) + if session, err = store.New(s.request, name); err != nil { + return + } session.name = name s.sessions[name] = sessionInfo{s: session, e: err} } -- cgit v1.2.3 From b5d868122c68458b92558e9239d6225af9106b52 Mon Sep 17 00:00:00 2001 From: Jonathan Gillham Date: Fri, 25 Oct 2013 11:01:54 +0100 Subject: Revert "Proposed change to Registry.Get function when CookieStore.New produces" This reverts commit 43ff70ebcff1674fba9aff126178f93076b32718. --- sessions.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sessions.go b/sessions.go index 72b6ecb..53111b3 100644 --- a/sessions.go +++ b/sessions.go @@ -144,9 +144,7 @@ func (s *Registry) Get(store Store, name string) (session *Session, err error) { if info, ok := s.sessions[name]; ok { session, err = info.s, info.e } else { - if session, err = store.New(s.request, name); err != nil { - return - } + session, err = store.New(s.request, name) session.name = name s.sessions[name] = sessionInfo{s: session, e: err} } -- cgit v1.2.3 From cb4af09e63b4fa547369c43a1fa62c2c4ce5c2b7 Mon Sep 17 00:00:00 2001 From: Jonathan Gillham Date: Fri, 25 Oct 2013 11:15:33 +0100 Subject: Updated store documentation. --- store.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/store.go b/store.go index a5cb867..5b43bc8 100644 --- a/store.go +++ b/store.go @@ -16,6 +16,15 @@ import ( ) // Store is an interface for custom session stores. +// +// Get should return a cached session. +// New should create and return a new session. +// Save should persist session to the underlying store implementation. +// +// Note that New should never return a nul session, even in the case of an error +// if using the Registry infrastructure for caching of sessions in your store. +// +// See CookieStore and FilesystemStore for examples. type Store interface { Get(r *http.Request, name string) (*Session, error) New(r *http.Request, name string) (*Session, error) -- cgit v1.2.3 From 3cb09c3e9541606b194a45b02b85176b6e4635f4 Mon Sep 17 00:00:00 2001 From: Jonathan Gillham Date: Fri, 25 Oct 2013 20:28:06 +0100 Subject: Improved Store interface comments. --- store.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/store.go b/store.go index 5b43bc8..5eaea81 100644 --- a/store.go +++ b/store.go @@ -17,17 +17,18 @@ import ( // Store is an interface for custom session stores. // -// Get should return a cached session. -// New should create and return a new session. -// Save should persist session to the underlying store implementation. -// -// Note that New should never return a nul session, even in the case of an error -// if using the Registry infrastructure for caching of sessions in your store. -// // See CookieStore and FilesystemStore for examples. type Store interface { + // Get should return a cached session. Get(r *http.Request, name string) (*Session, error) + + // New should create and return a new session. + // + // Note that New should never return a nil session, even in the case of + // an error if using the Registry infrastructure to cache the session. New(r *http.Request, name string) (*Session, error) + + // Save should persist session to the underlying store implementation. Save(r *http.Request, w http.ResponseWriter, s *Session) error } -- cgit v1.2.3