| Crates.io | exum |
| lib.rs | exum |
| version | 0.2.0 |
| created_at | 2025-10-04 04:35:14.144671+00 |
| updated_at | 2025-10-07 07:06:28.172066+00 |
| description | A lightweight Axum syntax sugar library |
| homepage | |
| repository | https://github.com/isyuah/exum |
| max_upload_size | |
| id | 1867509 |
| size | 98,015 |
一个轻量级的 Axum 语法糖库,提供更简洁的路由定义语法。
impl IntoResponse在 Cargo.toml 中添加依赖:
[dependencies]
exum = "0.1.0"
use exum::*;
#[get("/hello/:id")]
async fn hello(id: String, #[q] q: String) -> String {
format!("id: {}, query: {}", id, q)
}
#[post("/users")]
async fn create_user(#[b] user: User) -> String {
format!("Created user: {:?}", user)
}
// 使用 #[main] 宏自动处理应用初始化和配置加载
#[main]
async fn main() {
}
// 或者使用传统方式手动初始化
// #[tokio::main]
// async fn main() {
// let app = Application::build(ApplicationConfig::default());
// app.run().await;
// }
详细的文档请参考以下章节:
deref-app: 为 Application 实现 Deref trait,可以直接访问底层的 Routerapp_chain_ext: 为 Application 提供链式调用方法,支持更灵活的路由配置app_chain_ext_full: 包含 app_chain_ext 和静态文件服务功能layers: 获得一些Service, Layer以及fast_builder(如StaticFileServiceBuilder)full: 包含所有特性MIT License