
adminandClaude Code
b21b9448da
feat(routes): 27 条路由装配 + 404/405/catch-all 三层兜底 + main 启动装配
routes.rs:逐条注册 27 条路由(axum 0.8.9/matchit 0.8.4 不支持 {a,b}
多参数写法 ⇒ 每条具体路径单独注册);`auth::current_user` 收 &AppState
⇒ 用闭包包一层;探活端点 /api/health 返 {ok,tables,version}。
三层兜底(控制器裁决 S25 的顺序):build_router → .fallback(404 兜底)
→ .layer(405 改写) → .layer(catch-all) → .with_state(链尾)。
404 显式配 StatusCode::NOT_FOUND(fail() 恒 200);405 只改写「405 且
body 为空」的响应并保留 Allow 头;catch-all 只接 panic(DB 报错已在
handler 内被 db_error 接住),用 catch_unwind 手写,不引 tower/futures。
main.rs:按契约 §10 的 7 步装配 —— resolve_project_dir(从可执行文件
向上找 schema.sql + Cargo.toml 锚点,与 cwd 解耦)→ Config::from_env
→ 标识符白名单自检(开库之前,不过则打印人话并 exit 1)→ 开库建表
→ 两段式种子(失败 exit 1)→ 路由装配 → 绑定端口(失败 exit 1)。
子命令:--enc <明文> 打印 hex(退出码 0)、--help 打印用法、未知参数退出码 2。
不实现静态托管(Ruling P79);DDL 绝不可从 HTTP 下载由「不托管任何
文件」天然满足,另加 /db/schema.sql 与 /src/backend/db/schema.sql ⇒ 404 的守卫测试。
Co-Authored-By: Claude Code <[email protected]>