fix: 调整路由顺序,修复静态文件被JWT拦截的问题

- 将 /static/{tail:.*} 路由移到受保护 scope 之前
- 确保静态文件无需认证即可访问
This commit is contained in:
2026-04-15 11:51:59 +08:00
parent 913a235e5c
commit a819a0db91
9 changed files with 728 additions and 678 deletions

21
src/handlers/health.rs Normal file
View File

@@ -0,0 +1,21 @@
use actix_web::{web, get, HttpResponse, Responder};
use sqlx::postgres::PgPool;
#[get("/health")]
pub async fn health_check(pool: web::Data<PgPool>) -> impl Responder {
// 检查数据库连接
match sqlx::query("SELECT 1").fetch_one(pool.get_ref()).await {
Ok(_) => HttpResponse::Ok().json(serde_json::json!({
"status": "healthy",
"database": "connected"
})),
Err(e) => {
tracing::error!("健康检查失败: {}", e);
HttpResponse::ServiceUnavailable().json(serde_json::json!({
"status": "unhealthy",
"database": "disconnected",
"error": "数据库连接失败"
}))
}
}
}