Skip to content

Commit

Permalink
Add GetTime and SetTime to session provider (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilstrata authored Dec 7, 2023
1 parent a0a1b52 commit f9ae445
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package session

import "net/http"
import (
"net/http"
"time"
)

// Provider enables a way to interact with the underlying session store. Methods
// on the provider take a request in order to look up the associated session.
Expand All @@ -27,6 +30,11 @@ type Provider interface {
// does not exist, the default or zero value will be returned (i.e, nil).
GetBytes(key string) ([]byte, error)

// GetTime returns the time.Time for a given key from the session data. If the key
// does not exist, the default or zero value will be returned
// (i.e, 0001-01-01 00:00:00 +0000 UTC).
GetTime(key string) (time.Time, error)

// GetAny returns a session value based the provided key. If the key does not
// exist, the default or zero value will be returned (i.e, nil). This method is
// mainly exposed for backwards compatibility any may be deprecated in the
Expand All @@ -45,6 +53,9 @@ type Provider interface {
// SetBytes adds a key and the corresponding []byte value to the session data.
SetBytes(key string, value []byte) error

// SetTime adds a key and the corresponding time.Time value to the session data.
SetTime(key string, value time.Time) error

// Save saves all changes from the changelog to the underlying session store.
Save() error
}
Expand Down

0 comments on commit f9ae445

Please sign in to comment.