Skip to main content

auth_middleware

Function auth_middleware 

Source
pub async fn auth_middleware(
    request: Request<Body>,
    next: Next,
    expected_token: Option<String>,
) -> Result<Response, StatusCode>
Expand description

Middleware that validates bearer tokens when configured.

If expected_token is None, all requests pass through (no-op). If expected_token is Some, requests must include a matching Authorization: Bearer <token> header or receive a 401.