Skip to main content

require_session

Function require_session 

Source
pub async fn require_session(
    __arg0: State<AppState>,
    req: Request,
    next: Next,
) -> Response
Expand description

Middleware that enforces a valid session on the wrapped routes.

On reject:

  • a GET request that prefers text/html is redirected to /login?next=...
  • any other request gets a JSON 401.

ยงErrors

Returns the Error::Unauthenticated variant; the axum::response::IntoResponse impl will turn it into the appropriate response.