chore: clippy performance improvements

This commit is contained in:
Per Stark
2025-10-15 22:24:59 +02:00
parent 35ff4e1464
commit c3a7e8dc59
11 changed files with 51 additions and 55 deletions

View File

@@ -13,14 +13,12 @@ pub async fn api_auth(
mut request: Request,
next: Next,
) -> Result<Response, ApiError> {
let api_key = extract_api_key(&request).ok_or(ApiError::Unauthorized(
"You have to be authenticated".to_string(),
))?;
let api_key = extract_api_key(&request)
.ok_or_else(|| ApiError::Unauthorized("You have to be authenticated".to_string()))?;
let user = User::find_by_api_key(&api_key, &state.db).await?;
let user = user.ok_or(ApiError::Unauthorized(
"You have to be authenticated".to_string(),
))?;
let user =
user.ok_or_else(|| ApiError::Unauthorized("You have to be authenticated".to_string()))?;
request.extensions_mut().insert(user);