Documentation
¶
Index ¶
- Variables
- func GetSession(r *http.Request) (*sessions.Session, error)
- func GetSessionOrFail(w http.ResponseWriter, r *http.Request) (*sessions.Session, bool)
- func SessionError(w http.ResponseWriter, r *http.Request, err error)
- func SessionErrorRedirect(w http.ResponseWriter, r *http.Request, err error)
- type ContextValues
- type DirFS
- type FileSystem
- type OSDirFS
- type OSFS
Constants ¶
This section is empty.
Variables ¶
var SessionName string
SessionName is the cookie name used for storing session data.
var Store *sessions.CookieStore
Store holds the session store implementation.
Functions ¶
func GetSession ¶
GetSession returns the session from the request context if present, otherwise it retrieves the session from the session store.
func GetSessionOrFail ¶
GetSessionOrFail wraps GetSession and writes a 500 response if retrieving the session fails. It returns the session and a boolean indicating success.
func SessionError ¶
func SessionError(w http.ResponseWriter, r *http.Request, err error)
SessionError logs the error and clears the session cookie.
func SessionErrorRedirect ¶
func SessionErrorRedirect(w http.ResponseWriter, r *http.Request, err error)
SessionErrorRedirect clears the session and redirects to the login page when an error occurs retrieving the session.
Types ¶
type ContextValues ¶
type ContextValues string
ContextValues represents context key names used across the application.
type DirFS ¶
type DirFS interface {
FileSystem
MkdirAll(path string, perm fs.FileMode) error
Stat(name string) (fs.FileInfo, error)
Remove(name string) error
}
DirFS extends FileSystem with directory operations used by startup checks.
type FileSystem ¶
type FileSystem interface {
ReadFile(name string) ([]byte, error)
WriteFile(name string, data []byte, perm fs.FileMode) error
}
FileSystem abstracts basic file operations so tests can use an in-memory implementation.
func UseMemFS ¶
func UseMemFS(t *testing.T) FileSystem
UseMemFS returns an in-memory FileSystem for tests.