Skip to main content

rust_web_utils/
lib.rs

1//! rust-web-utils: CZL Web 服务的公共工具库, 与 Go 版
2//! [go-web-utils](https://github.com/woodchen-ink/go-web-utils) 语义对齐。
3//!
4//! 基于 [`http`] crate 的通用类型 (`HeaderMap` / `Request` / `Response`) 实现,
5//! 不绑定具体框架; 开启 `axum` feature 后提供 Axum 集成, `tower` feature 提供
6//! tower 中间件。
7//!
8//! | 模块 | 用途 | feature |
9//! |------|------|---------|
10//! | [`iputil`] | 客户端真实 IP、可信代理、IP 校验与 CIDR | `iputil` |
11//! | [`uautil`] | 机器人 / 浏览器识别与拦截中间件 | `uautil` (`tower` 开中间件) |
12//! | [`resputil`] | 统一 JSON 响应 `{ code, data, msg }` | `resputil` |
13//! | [`timex`] | 业务时区初始化与自然日 / 周 / 月边界 | `timex` |
14//! | [`cookieutil`] | 安全默认值的认证 Cookie 与 CSRF double-submit | `cookieutil` |
15//! | [`cronutil`] | 空轮退避、防重叠、去抖聚合队列 | `cronutil` |
16//! | [`nextstatic`] | Next.js 15/16 静态导出托管 | `nextstatic` |
17//!
18//! 默认开启全部模块 (不含 `axum` / `tower`)。按需裁剪:
19//!
20//! ```toml
21//! [dependencies]
22//! rust-web-utils = { git = "https://github.com/woodchen-ink/rust-web-utils", tag = "v0.1.0", default-features = false, features = ["iputil", "resputil", "axum"] }
23//! ```
24//!
25//! 完整文档: <https://rust-web-utils.czl.net/docs>
26#![cfg_attr(docsrs, feature(doc_cfg))]
27
28#[cfg(feature = "cookieutil")]
29pub mod cookieutil;
30#[cfg(feature = "cronutil")]
31pub mod cronutil;
32#[cfg(feature = "iputil")]
33pub mod iputil;
34#[cfg(feature = "nextstatic")]
35pub mod nextstatic;
36#[cfg(feature = "resputil")]
37pub mod resputil;
38#[cfg(feature = "timex")]
39pub mod timex;
40#[cfg(feature = "uautil")]
41pub mod uautil;