Skip to content

Commit

Permalink
Merge pull request #18 from joicemjoseph/feat/multi-set
Browse files Browse the repository at this point in the history
fixes #17 SetMulti session method added.
  • Loading branch information
knadh authored May 10, 2024
2 parents 215a0db + 4a8df93 commit 001d993
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ func (s *Session) Set(key string, val interface{}) error {
return s.manager.store.Set(s.cookie.Value, key, val)
}

// SetMulti sets all values in the session.
// Its up to store to commit all previously
// set values at once or store it on each set.
func (s *Session) SetMulti(values map[string]interface{}) error {
// Check if session is set before accessing it
if !s.isSet {
return ErrInvalidSession
}

for k, v := range values {
if err := s.manager.store.Set(s, s.cookie.Value, k, v); err != nil {

Check failure on line 256 in session.go

View workflow job for this annotation

GitHub Actions / Go 1.18 Tests

too many arguments in call to s.manager.store.Set

Check failure on line 256 in session.go

View workflow job for this annotation

GitHub Actions / Go 1.19 Tests

too many arguments in call to s.manager.store.Set

Check failure on line 256 in session.go

View workflow job for this annotation

GitHub Actions / Go 1.20 Tests

too many arguments in call to s.manager.store.Set

Check failure on line 256 in session.go

View workflow job for this annotation

GitHub Actions / Go 1.21 Tests

too many arguments in call to s.manager.store.Set
return err
}
}

return nil
}

// Commit commits all set to store. Its up to store to commit
// all previously set values at once or store it on each set.
func (s *Session) Commit() error {
Expand Down

0 comments on commit 001d993

Please sign in to comment.