Expand description
Tower middleware layer that loads, validates, and persists sessions for every request.
The public entry point is layer, which wraps a SessionStore in a
Tower Layer / Service pair. The middleware:
- Reads the session token from the request cookie.
- Loads the matching, non-expired session from the database.
- Optionally validates a server-side request fingerprint.
- Injects shared state so the
crate::SessionManagerextractor can operate within the handler. - After the handler returns, applies any pending session action (set cookie, remove cookie, or touch expiry).
Structs§
- Session
Context Layer - Tower
Layerproduced bylayer. - Session
Middleware - Tower
Serviceproduced bySessionContextLayer.
Functions§
- layer
- Create a session middleware layer from a
SessionStore. - user_
id_ from_ extensions - Extract the current user ID from request extensions without going through
the full
crate::SessionManagerextractor.