Documentation
¶
Index ¶
- func SessionFromHttpResponse[T any](manager *SessionManager[T], httpResponse *http.Response) *T
- type Session
- type SessionManager
- func (m *SessionManager[TData]) Create(response http.ResponseWriter, values TData)
- func (m *SessionManager[TData]) Destroy(response http.ResponseWriter, request *http.Request)
- func (m *SessionManager[TData]) Get(request *http.Request) *TData
- func (m *SessionManager[TData]) PruneSessions()
- func (m *SessionManager[TData]) SessionCount() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SessionFromHttpResponse ¶
func SessionFromHttpResponse[T any](manager *SessionManager[T], httpResponse *http.Response) *T
Types ¶
type SessionManager ¶
type SessionManager[TData any] struct { // contains filtered or unexported fields }
func NewSessionManager ¶
func NewSessionManager[TData any](sessionLifetime time.Duration) *SessionManager[TData]
NewSessionManager creates a new session manager. It uses in-memory storage.
func (*SessionManager[TData]) Create ¶
func (m *SessionManager[TData]) Create(response http.ResponseWriter, values TData)
Create creates a new session and sets a session cookie. The given values are stored in the session, which can be retrieved later using Get.
func (*SessionManager[TData]) Destroy ¶
func (m *SessionManager[TData]) Destroy(response http.ResponseWriter, request *http.Request)
func (*SessionManager[TData]) Get ¶
func (m *SessionManager[TData]) Get(request *http.Request) *TData
Get retrieves the session for the given request. The session is retrieved using the session cookie. If no session is found, nil is returned.
func (*SessionManager[TData]) PruneSessions ¶
func (m *SessionManager[TData]) PruneSessions()
PruneSessions removes expired sessions.
func (*SessionManager[TData]) SessionCount ¶
func (m *SessionManager[TData]) SessionCount() int
Click to show internal directories.
Click to hide internal directories.