feat: 完善生产级 Rust Web 模板

This commit is contained in:
2026-07-21 16:00:03 +08:00
parent fb30d5da1a
commit ce89569bf3
58 changed files with 2042 additions and 349 deletions
+18
View File
@@ -2,6 +2,11 @@
[server]
host = "0.0.0.0"
port = 3000
request_timeout_seconds = 30
max_body_bytes = 1048576
concurrency_limit = 256
rate_limit_per_minute = 120
cors_origins = ["http://localhost:3000", "http://localhost:5173"]
[database]
# 数据库类型: mysql, sqlite, postgresql
@@ -27,7 +32,20 @@ access_token_expiration_minutes = 15 # access_token 15 分钟
refresh_token_expiration_days = 7 # refresh_token 7 天
[redis]
enabled = false
host = "localhost"
port = 6379
password = "" # 可选
db = 0
[email]
enabled = false
smtp_host = "smtp.example.com"
smtp_port = 587
smtp_username = ""
smtp_password = ""
from_email = "noreply@example.com"
from_name = "Web Rust Template"
verification_code_ttl_seconds = 600
queue_enabled = false
worker_pool_size = 2
+18
View File
@@ -3,6 +3,11 @@
[server]
host = "0.0.0.0" # 服务器监听地址(0.0.0.0=允许所有网络访问)
port = 3000 # 服务器监听端口(确保防火墙已开放)
request_timeout_seconds = 30
max_body_bytes = 1048576
concurrency_limit = 256
rate_limit_per_minute = 120
cors_origins = ["https://example.com"]
[database]
database_type = "postgresql" # 数据库类型:sqlite/mysql/postgresql
@@ -19,11 +24,24 @@ access_token_expiration_minutes = 15 # Access Token 过期时间(
refresh_token_expiration_days = 7 # Refresh Token 过期时间(天)
[redis]
enabled = true
host = "localhost" # Redis 服务器地址
port = 6379 # Redis 端口(默认 6379
password = "" # Redis 密码(强烈建议设置密码)
db = 0 # Redis 数据库编号(0-15
[email]
enabled = false
smtp_host = "smtp.example.com"
smtp_port = 587
smtp_username = ""
smtp_password = ""
from_email = "noreply@example.com"
from_name = "Web Rust Template"
verification_code_ttl_seconds = 600
queue_enabled = true
worker_pool_size = 4
# 安全检查清单:部署前请确认
# ✅ 1. 已修改 jwt_secret 为强随机字符串
# ✅ 2. 已修改数据库密码为强密码