exum 0.1.9

A lightweight Axum syntax sugar library
Documentation

Exum

一个轻量级的 Axum 语法糖库,提供更简洁的路由定义语法。

特性

  • 🚀 简洁的路由宏语法
  • 📦 自动参数提取和类型转换
  • 🔧 支持多种HTTP方法
  • 🎯 路径参数自动解析
  • 📝 查询参数和请求体处理
  • ⚡ 省略返回值时默认返回 impl IntoResponse
  • 🌍 环境自动检测和配置覆盖
  • 🔧 环境变量注入支持
  • 📁 多环境配置文件管理
  • 🔗 链式调用支持(AppChainExt)

安装

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)
}

#[tokio::main]
async fn main() {
    let app = Application::build(ApplicationConfig::default());
    app.run().await;
}

文档

详细的文档请参考以下章节:

Features

  • deref-app: 为 Application 实现 Deref trait,可以直接访问底层的 Router
  • app_chain_ext: 为 Application 提供链式调用方法,支持更灵活的路由配置
  • app_chain_ext_full: 包含 app_chain_ext 和静态文件服务功能
  • full: 包含所有特性

许可证

MIT License