WebR brings the developer experience of Spring Boot to the Rust ecosystem — macro-driven controllers, automatic dependency injection, ORM and cache, configuration management, and a built-in middleware system, all built on top of Axum.
use webr::prelude::*;
#[controller]
pub struct HelloController;
#[controller]
impl HelloController {
#[get("/")]
async fn index(&self) -> String {
"hello world".to_string()
}
}
#[webr::main]
async fn main(_app: &mut AppBuilder) -> Result<()> {
Ok(())
}If everything goes well, visit http://localhost:8080 and you will see hello world.
Full documentation is available at WebR Document.
- Quick Start
- Dependency Injection
- Configuration
- Routing & Controllers
- Request Handling & Validation
- Response & Error Handling
- Middleware & Authentication
- File Upload & Download
- SSE
- Database
- Cache
- Performance
The examples directory contains some example projects that you can use to quickly get familiar with WebR.
| Example | Description |
|---|---|
hello-world |
Controllers, DI, config binding, unified response |
middleware |
Custom auth middleware, path-scoped routing, CORS |
file-upload |
Multi-file upload, file download, inline preview |
sse |
Server-Sent Events streaming |
orm |
Entity CRUD, #[sql] dynamic queries, #[tx] transactions |
cache |
Cache module usage |
axum-bench |
Raw axum vs WebR performance benchmark |
Run an example:
cd examples/hello-world
cargo runwebr/
├── crates/
│ ├── webr-core/ # Core primitives: DI, config, context, Inject, Error
│ ├── webr-web/ # Web layer: AppBuilder, extractors, middleware, response, router
│ ├── webr-db/ # Database: connection pool, transactions, ORM support
│ ├── webr-cache/ # Cache: Memory / Sled / Redis backends
│ ├── webr-macros/ # Procedural macros: controller, component, config, entity, sql, tx, HttpError
│ └── webr-middleware/ # Middleware: authentication, authorization, request body caching
├── examples/ # Example applications
└── src/lib.rs # Umbrella crate, unified re-export of all public APIs
Apache 2.0
