feat: [阶段1] 项目初始化和基础设置
- 创建 Cargo.toml 配置文件,包含所有必要依赖 - 建立完整的项目模块结构(config, models, handlers, routes, services, storage, middleware, utils) - 实现用户数据模型和内存存储 - 创建基础的 HTTP 处理器和路由配置 - 添加错误处理和 JWT 认证中间件 - 配置环境变量和日志系统 - 创建项目文档和学习指南 - 服务器可以成功编译和启动
This commit is contained in:
22
src/handlers/mod.rs
Normal file
22
src/handlers/mod.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
//! HTTP 请求处理器模块
|
||||
|
||||
pub mod user;
|
||||
|
||||
use axum::{response::Json, http::StatusCode};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// 根路径处理器
|
||||
pub async fn root() -> Json<Value> {
|
||||
Json(json!({
|
||||
"message": "欢迎使用 Rust User API",
|
||||
"version": "0.1.0"
|
||||
}))
|
||||
}
|
||||
|
||||
/// 健康检查处理器
|
||||
pub async fn health_check() -> (StatusCode, Json<Value>) {
|
||||
(StatusCode::OK, Json(json!({
|
||||
"status": "healthy",
|
||||
"timestamp": chrono::Utc::now()
|
||||
})))
|
||||
}
|
Reference in New Issue
Block a user