Documentation ¶
Index ¶
- type SessionStore
- func (st *SessionStore[T]) DeleteSession(r *http.Request)
- func (st *SessionStore[T]) GetSessionFromCtx(r *http.Request) *T
- func (st *SessionStore[T]) GetSessionFromRequest(r *http.Request) *T
- func (st *SessionStore[T]) InitStore(name string, itemExpiry time.Duration)
- func (st *SessionStore[T]) LoadSession(next http.Handler) http.Handler
- func (st *SessionStore[T]) PutSession(w http.ResponseWriter, r *http.Request, sess *T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessionStore ¶
type SessionStore[T any] struct { // contains filtered or unexported fields }
SessionStore holds the session data and settings
func (*SessionStore[T]) DeleteSession ¶
func (st *SessionStore[T]) DeleteSession(r *http.Request)
DeleteSession will delete the session from the SessionStore.
func (*SessionStore[T]) GetSessionFromCtx ¶
func (st *SessionStore[T]) GetSessionFromCtx(r *http.Request) *T
GetSessionFromCtx retrieves the session from the http.Request context. The function will return nil if the session does not exist within the http.Request context.
func (*SessionStore[T]) GetSessionFromRequest ¶
func (st *SessionStore[T]) GetSessionFromRequest(r *http.Request) *T
GetSessionFromRequest retrieves the session from the http.Request cookies. The function will return nil if the session does not exist within the http.Request cookies.
func (*SessionStore[T]) InitStore ¶
func (st *SessionStore[T]) InitStore(name string, itemExpiry time.Duration)
Init will initialize the SessionStore object
func (*SessionStore[T]) LoadSession ¶
func (st *SessionStore[T]) LoadSession(next http.Handler) http.Handler
LoadSession will load the session into the http.Request context. A http.StatusUnauthorized will be retuned to the client if no session can be found.
func (*SessionStore[T]) PutSession ¶
func (st *SessionStore[T]) PutSession(w http.ResponseWriter, r *http.Request, sess *T)
PutSession will store the session in the SessionStore. The session will automatically expire after defined SessionStore.sessionExpiration.