pub async fn auth_guard(
__arg0: State<State>,
request: Request,
next: Next,
) -> Result<Response>Expand description
Middleware that guards protected routes by validating the session token.
Extracts the Bearer token from the Authorization header, computes its hash,
and checks the in-memory cache. If missing from the cache, it verifies the
token against the database and caches the result for future requests.
ยงErrors
- Returns an
Unauthorizedif theAuthorizationheader is missing, malformed, or contains an invalid/expired token. - Returns a
BadRequestif the token string cannot be serialized. - Returns an internal error if a database query fails.