Documentation
¶
Index ¶
- type SurrealSession
- type SurrealStore
- func (store *SurrealStore) Cleanup(interval time.Duration) (chan<- struct{}, <-chan struct{})
- func (store *SurrealStore) Close()
- func (store *SurrealStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (db *SurrealStore) MaxAge(age int)
- func (db *SurrealStore) MaxLength(l int)
- func (store *SurrealStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (store *SurrealStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (store *SurrealStore) StopCleanup(quit chan<- struct{}, done <-chan struct{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SurrealSession ¶
type SurrealSession struct { ID *models.RecordID `json:"id,omitempty"` Data string `json:"data"` CreatedOn models.CustomDateTime `json:"created_on"` ModifiedOn models.CustomDateTime `json:"modified_on"` ExpiresOn models.CustomDateTime `json:"expires_on"` }
type SurrealStore ¶
type SurrealStore struct { Codecs []securecookie.Codec Options *sessions.Options DB *surrealdb.DB }
func NewSurrealStore ¶
func NewSurrealStore(db *surrealdb.DB, keyPairs ...[]byte) (*SurrealStore, error)
func (*SurrealStore) Cleanup ¶
func (store *SurrealStore) Cleanup(interval time.Duration) (chan<- struct{}, <-chan struct{})
Cleanup runs a background goroutine every interval that deletes expired sessions from the database.
The design is based on https://github.com/yosssi/boltstore
func (*SurrealStore) Close ¶
func (store *SurrealStore) Close()
func (*SurrealStore) MaxAge ¶
func (db *SurrealStore) MaxAge(age int)
MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.
func (*SurrealStore) MaxLength ¶
func (db *SurrealStore) 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 session, use with caution. The default for a new PGStore is 4096.
func (*SurrealStore) New ¶
New returns a new session for the given name without adding it to the registry.
func (*SurrealStore) Save ¶
func (store *SurrealStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save saves the given session into the database and deletes cookies if needed
func (*SurrealStore) StopCleanup ¶
func (store *SurrealStore) StopCleanup(quit chan<- struct{}, done <-chan struct{})
StopCleanup stops the background cleanup from running.