Documentation
¶
Index ¶
- type Data
- type FlashData
- type Manager
- func (m *Manager) Clear() *http.Cookie
- func (m *Manager) ClearFlash() *http.Cookie
- func (m *Manager) Create(userID int64, username string) (*http.Cookie, error)
- func (m *Manager) GetFlash(r *http.Request) *FlashData
- func (m *Manager) Parse(r *http.Request) (*Data, error)
- func (m *Manager) SetFlash(data *FlashData) (*http.Cookie, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
UserID int64 `json:"u"`
Username string `json:"n"`
ExpiresAt time.Time `json:"e"`
}
Data contains the session information stored in the cookie.
type FlashData ¶
type FlashData struct {
RecoveryCodes []string `json:"rc,omitempty"`
}
FlashData contains temporary data that is cleared after reading.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles session cookie creation and parsing.
func NewManager ¶
func NewManager(cfg *config.SessionConfig, secure bool) (*Manager, error)
NewManager creates a new session manager.
func (*Manager) ClearFlash ¶
ClearFlash returns a cookie that clears the flash data.
func (*Manager) GetFlash ¶
GetFlash reads and returns the flash data. Returns nil if no flash cookie exists.
Click to show internal directories.
Click to hide internal directories.