hwhkit/lib.rs
1//! # HwhKit
2//!
3//! 一个用于快速构建 Web 服务的 Rust 工具库,支持前后端分离和不分离两种架构。
4//!
5//! ## 特性
6//!
7//! - 🚀 一键构建 Web 服务
8//! - 🔧 灵活的中间件系统
9//! - 📝 支持模板渲染(前后端不分离)
10//! - 🌐 支持 API 服务(前后端分离)
11//! - ⚙️ 基于配置的中间件装载
12//!
13//! ## 快速开始
14//!
15//! ```rust
16//! use hwhkit::WebServerBuilder;
17//!
18//! #[tokio::main]
19//! async fn main() {
20//! let app = WebServerBuilder::new()
21//! .config_from_file("config.toml")
22//! .build()
23//! .await
24//! .expect("Failed to build server");
25//!
26//! app.serve().await;
27//! }
28//! ```
29
30pub mod builder;
31pub mod config;
32pub mod error;
33pub mod middleware;
34pub mod server;
35
36#[cfg(feature = "templates")]
37pub mod templates;
38
39pub use builder::WebServerBuilder;
40pub use config::Config;
41pub use error::{Error, Result};
42pub use server::WebServer;
43
44// 重新导出常用的类型
45pub use axum::{
46 extract::{Json, Path, Query, State},
47 http::{Method, StatusCode},
48 response::{Html, IntoResponse},
49 routing::{delete, get, patch, post, put, Router},
50};
51
52pub use serde::{Deserialize, Serialize};
53pub use tokio;
54pub use tower_http::cors::CorsLayer;