Skip to content

Commit

Permalink
session: publicize HasChanged method (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon authored Dec 1, 2023
1 parent 59efe43 commit 56e6da6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ type Session interface {
Flush()
// Encode encodes session data to binary.
Encode() ([]byte, error)

// hasChanged returns whether the session has changed.
hasChanged() bool
// HasChanged returns whether the session has changed.
HasChanged() bool
}

// CookieOptions contains options for setting HTTP cookies.
Expand Down Expand Up @@ -193,7 +192,7 @@ func Sessioner(opts ...Options) flamego.Handler {
c.MapTo(flash, (*Flash)(nil))
c.Next()

if sess.hasChanged() {
if sess.HasChanged() {
err = store.Save(c.Request().Context(), sess)
} else {
err = store.Touch(c.Request().Context(), sess.ID())
Expand Down
2 changes: 1 addition & 1 deletion type.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *BaseSession) Encode() ([]byte, error) {
return s.encoder(s.data)
}

func (s *BaseSession) hasChanged() bool {
func (s *BaseSession) HasChanged() bool {
s.lock.RLock()
defer s.lock.RUnlock()
return s.changed
Expand Down

0 comments on commit 56e6da6

Please sign in to comment.