- 创建 Cargo.toml 配置文件,包含所有必要依赖 - 建立完整的项目模块结构(config, models, handlers, routes, services, storage, middleware, utils) - 实现用户数据模型和内存存储 - 创建基础的 HTTP 处理器和路由配置 - 添加错误处理和 JWT 认证中间件 - 配置环境变量和日志系统 - 创建项目文档和学习指南 - 服务器可以成功编译和启动
44 lines
968 B
TOML
44 lines
968 B
TOML
[package]
|
|
name = "rust-user-api"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
authors = ["Your Name <your.email@example.com>"]
|
|
description = "A REST API server for user management built with Rust and Axum"
|
|
|
|
[dependencies]
|
|
# Web 框架
|
|
axum = "0.7"
|
|
tokio = { version = "1.0", features = ["full"] }
|
|
tower = "0.4"
|
|
tower-http = { version = "0.5", features = ["cors", "trace"] }
|
|
|
|
# 序列化
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
serde_json = "1.0"
|
|
|
|
# 时间处理
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
|
|
# UUID 生成
|
|
uuid = { version = "1.0", features = ["v4", "serde"] }
|
|
|
|
# 环境变量
|
|
dotenv = "0.15"
|
|
|
|
# 日志
|
|
tracing = "0.1"
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
|
|
# 密码哈希
|
|
bcrypt = "0.15"
|
|
|
|
# JWT 认证
|
|
jsonwebtoken = "9.0"
|
|
|
|
# 验证
|
|
validator = { version = "0.16", features = ["derive"] }
|
|
|
|
# HTTP 客户端(用于测试)
|
|
[dev-dependencies]
|
|
reqwest = { version = "0.11", features = ["json"] }
|
|
tokio-test = "0.4" |