KennethCheng
|
c6ad3883f8
|
feat(gotify): Phase 3 C1 — Gotify REST API client
- src/gotify/api.rs: blocking reqwest 封装(§14);health / applications
/ messages 三个方法;Bearer token 用 HeaderValue::set_sensitive
标记,日志绝不泄露(§20);10s per-request timeout
- src/gotify/model.rs: GotifyHealth / GotifyApplication / GotifyMessage
DTO 镜像官方 wire schema;defaultPriority 加 rename(camelCase)
- src/gotify/mod.rs: re-export
- src/error.rs: 加 AppError::Gotify(String)
- Cargo.toml: reqwest 0.12 (blocking + json + rustls-tls) 从注释升级为真
依赖(AGENTS.md §44 模板里早就列了,Phase 1 当时推迟)
- tests/gotify_api.rs: 6 个 JSON 解析测试
避坑:
- reqwest 0.12 默认 log Bearer token;要 set_sensitive(true) 才行
- reqwest::Error 转 AppError 不能用返回 impl Fn 的 helper(path 是
&str 不是 'static)—— 改成每个调用点 inline closure
- Gotify 的 defaultPriority 是 camelCase,其他字段都是单字;
用 #[serde(rename = "defaultPriority")] 单点 rename 而不是全局
rename_all = "camelCase"(因为 Rust 端字段名是 snake_case)
验证:cargo build / build --release 都 exit 0,0 warning
- cargo test --test gotify_api: 6 passed; 0 failed
- debug 27.88 MB, subsystem = WINDOWS_CUI
- release 8.10 MB, subsystem = WINDOWS_GUI(reqwest 加进 release
LTO 后体积几乎没变——rustls 是大头但被 strip + LTO 吃掉了)
|
2026-09-19 04:57:44 +08:00 |
|