Documentation
¶
Overview ¶
Package sqlitestore store provides a sqlite-backed session store using database.DB
Index ¶
- Variables
- func NewDomainEmbeds() database.DomainEmbeds
- type Session
- type SqliteStore
- func (ss *SqliteStore) AddSession(ctx context.Context, sess Session) (err error)
- func (ss *SqliteStore) Cleanup(ctx context.Context) (done bool, err error)
- func (ss *SqliteStore) DeleteExpiredSessions(ctx context.Context, threshold time.Time) (err error)
- func (ss *SqliteStore) DeleteOldCreatedSessions(ctx context.Context, timeout time.Duration, threshold time.Time) (err error)
- func (ss *SqliteStore) DeleteSession(ctx context.Context, id string) (err error)
- func (ss *SqliteStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (ss *SqliteStore) GetSession(ctx context.Context, id string) (sess Session, err error)
- func (ss *SqliteStore) MaxAge(age int)
- func (ss *SqliteStore) MaxLength(l int)
- func (ss *SqliteStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (ss *SqliteStore) PeriodicallyCleanup(ctx context.Context, interval time.Duration) error
- func (ss *SqliteStore) Save(r *http.Request, w http.ResponseWriter, s *sessions.Session) error
- func (ss *SqliteStore) UpdateSession(ctx context.Context, sess Session) (err error)
Constants ¶
This section is empty.
Variables ¶
var MigrationFiles []string = []string{
"1-initialize-schema-v0.3.0",
}
Functions ¶
func NewDomainEmbeds ¶
func NewDomainEmbeds() database.DomainEmbeds
Types ¶
type SqliteStore ¶
type SqliteStore struct { Codecs []securecookie.Codec Options *sessions.Options AbsoluteTimeout time.Duration // contains filtered or unexported fields }
SqliteStore stores sessions in a godest sqlite-backed database.DB.
func NewSqliteStore ¶
func NewSqliteStore( db *database.DB, absoluteTimeout time.Duration, keyPairs ...[]byte, ) *SqliteStore
NewSqliteStore returns a new SqliteStore.
The db argument should be a database.DB with a "sessions_session" table already initialized according to the schema defined by the migrations in NewDomainEmbeds.
See sessions.NewCookieStore for a description of the other parameters.
func (*SqliteStore) AddSession ¶
func (ss *SqliteStore) AddSession(ctx context.Context, sess Session) (err error)
func (*SqliteStore) Cleanup ¶ added in v0.5.1
func (ss *SqliteStore) Cleanup(ctx context.Context) (done bool, err error)
func (*SqliteStore) DeleteExpiredSessions ¶
func (*SqliteStore) DeleteOldCreatedSessions ¶ added in v0.5.1
func (*SqliteStore) DeleteSession ¶
func (ss *SqliteStore) DeleteSession(ctx context.Context, id string) (err error)
func (*SqliteStore) GetSession ¶
func (*SqliteStore) MaxAge ¶
func (ss *SqliteStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting session.Options.MaxAge = -1 for that session.
func (*SqliteStore) MaxLength ¶
func (ss *SqliteStore) MaxLength(l int)
MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a sesson, use with caution. The default for a new SqliteStore is 4096 (default for securecookie).
func (*SqliteStore) New ¶
New creates and returns a session for the given name without adding it to the registry.
func (*SqliteStore) PeriodicallyCleanup ¶
func (*SqliteStore) Save ¶
func (ss *SqliteStore) Save(r *http.Request, w http.ResponseWriter, s *sessions.Session) error
Save adds a single session to the response.
If the Options.MaxAge of the session is <= 0 then the session record will be deleted from the database. With this process it properly enforces session cookie handling, so no need to trust the web browser's cookie management.
func (*SqliteStore) UpdateSession ¶
func (ss *SqliteStore) UpdateSession(ctx context.Context, sess Session) (err error)