style: format seluruh workspace dengan cargo fmt
Menyeragamkan format kode sesuai rustfmt (126 file). Sebelumnya lefthook pre-commit 'cargo fmt --check' akan gagal pada commit apa pun.
This commit is contained in:
@@ -105,7 +105,9 @@ pub async fn login_handler(
|
||||
serde_json::from_str(&content)
|
||||
.map_err(|e| ApiError::Internal(format!("Failed to parse users: {e}")))?
|
||||
} else {
|
||||
return Err(ApiError::Unauthorized("Invalid username or password".into()));
|
||||
return Err(ApiError::Unauthorized(
|
||||
"Invalid username or password".into(),
|
||||
));
|
||||
};
|
||||
|
||||
// Look up the user
|
||||
@@ -121,7 +123,9 @@ pub async fn login_handler(
|
||||
.map_err(|e| ApiError::Internal(format!("Password verification failed: {e}")))?;
|
||||
|
||||
if !valid {
|
||||
return Err(ApiError::Unauthorized("Invalid username or password".into()));
|
||||
return Err(ApiError::Unauthorized(
|
||||
"Invalid username or password".into(),
|
||||
));
|
||||
}
|
||||
|
||||
// Generate tokens
|
||||
@@ -205,9 +209,7 @@ pub async fn register_handler(
|
||||
|
||||
// Check uniqueness
|
||||
if users.contains_key(&req.username) {
|
||||
return Err(ApiError::Conflict(
|
||||
"Username already exists".into(),
|
||||
));
|
||||
return Err(ApiError::Conflict("Username already exists".into()));
|
||||
}
|
||||
|
||||
// Persist
|
||||
|
||||
@@ -136,7 +136,8 @@ pub async fn chat_completions_handler(
|
||||
None, // No tool definitions for basic chat
|
||||
req.max_tokens,
|
||||
req.temperature,
|
||||
).await
|
||||
)
|
||||
.await
|
||||
.map_err(|e| ApiError::ChatProxy(format!("LLM request failed: {e}")))?;
|
||||
|
||||
let (prompt_tokens, completion_tokens) = usage.unwrap_or((0, 0));
|
||||
|
||||
@@ -91,8 +91,8 @@ pub async fn delete_session_handler(
|
||||
return Err(ApiError::BadRequest("Session ID is required".into()));
|
||||
}
|
||||
|
||||
let session_id =
|
||||
SessionId::new(&id).map_err(|e| ApiError::BadRequest(format!("Invalid session ID: {e}")))?;
|
||||
let session_id = SessionId::new(&id)
|
||||
.map_err(|e| ApiError::BadRequest(format!("Invalid session ID: {e}")))?;
|
||||
|
||||
state.session_service.archive_session(session_id)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user