一个基于Axum实现的,更符合Java开发者习惯的Rust生态的Web框架
WebR 简介一个轻量的 Rust Web 框架基于 Axum 构建。提供宏驱动控制器、自动依赖注入、多文件配置管理和中间件系统旨在简化 Rust 中的 Web 开发。WebR 引入了 Java 系的框架中的 DI、Controller、Component和自动配置等概念在保证性能的同时帮助开发者更快速的使用 Rust 构建 Web 应用。同时也内置了轻量的ORM可通过类似Mybatis XML实现动态SQL。开源地址https://github.com/xgpxg/webr文档https://xgpxg.github.io/webr特性概览宏驱动路由 — #[controller] / #[get] / #[post]零样板DI 配置管理 — #[component] / #[config] 声明式注入多 Profile 切换中间件 — 全局/路径级中间件内置 CORS、日志、Panic 恢复请求处理 — JSON / Query / Form / Header 提取器Multipart 上传SSE 推送错误处理 — #[derive(HttpError)] 快速映射 HTTP 状态码数据库 — 连接池、#[sql] 动态查询、#[tx] 事务缓存 — Memory / Sled / Redis 统一 API快速开始创建第一个 WebR 应用并运行起来。创建项目cargonew my-appcdmy-app添加依赖编辑Cargo.toml[dependencies] webr { version 0.1 }创建配置文件config/application.toml[server] port 8080编写代码src/main.rsusewebr::prelude::*;#[controller]pubstructHelloController;#[controller]implHelloController{#[get(/)]asyncfnindex(self)-String{hello world.to_string()}}// 入口函数#[webr::main]asyncfnmain(_app:mutAppBuilder)-Result(){Ok(())}启动cargorun如果你看到以下输出则说明启动成功2026-07-06T06:29:41.284926Z INFO webr_web::app: Starting WebR application... 2026-07-06T06:29:41.285005Z INFO webr_web::app: Configuration loaded: profiledev, files[config/application.toml] 2026-07-06T06:29:41.285337Z INFO webr_web::app: Route mappings: 2026-07-06T06:29:41.285390Z INFO webr_web::app: GET / → HelloController 2026-07-06T06:29:41.285633Z INFO webr_web::app: WebR started on http://0.0.0.0:8080访问 http://localhost:8080/ 查看结果。项目目前仍处于开发版本生产不可用欢迎感兴趣的同学提PR。