Ruffus is a web framework for Rust inspired by Express.js, designed to make building web APIs fast, simple, and enjoyable. With an ergonomic API and powerful async runtime, Ruffus lets you focus on building features, not fighting the framework.
use ;
async
✨ Features
- 🚀 Blazing Fast - Built on Tokio and Hyper for maximum performance
- 🎯 Type-Safe - Leverage Rust's type system to catch errors at compile time
- 🔌 Middleware - Composable middleware for cross-cutting concerns
- 📦 JSON Support - First-class JSON serialization with Serde
- 🛣️ Flexible Routing - Express-style routing with path parameters
- ⚡ Async/Await - Native async support for non-blocking I/O
- 🎨 Ergonomic API - Intuitive, chainable methods inspired by Express.js
- 🔧 Modular - Organize routes with routers and mount them anywhere
📦 Installation
Add Ruffus to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= { = "1.0", = ["derive"] }
🚀 Quick Start
Basic Server
use ;
async
JSON API
use ;
use ;
async
Middleware
use ;
use async_trait;
;
async
Routers
use ;
async
📚 Documentation
For detailed documentation, visit docs.rs/ruffus.
Core Concepts
- Getting Started - Your first Ruffus application
- Routing - Define routes and handle requests
- Middleware - Add cross-cutting functionality
- Request & Response - Work with HTTP data
- Error Handling - Handle errors gracefully
- Testing - Test your Ruffus applications
🎯 Examples
Check out the examples directory for more:
- Basic Server - Simple hello world
- JSON API - REST API with JSON
- Middleware - Custom middleware
- Routers - Organize routes
- Full API - Complete REST API example
Run an example:
🔧 API Overview
Application
let mut app = new;
app.get; // GET route
app.post; // POST route
app.put; // PUT route
app.delete; // DELETE route
app.patch; // PATCH route
app.use_middleware; // Add middleware
app.mount; // Mount router
app.listen.await?; // Start server
Request
req.method; // HTTP method
req.uri; // Request URI
req.headers; // HTTP headers
req.param; // Path parameter
req.query; // Query parameter
req..await?; // Parse JSON body
Response
text; // Plain text response
json?; // JSON response
new
.status
.header
.text; // Builder pattern
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development
# Clone the repository
# Run tests
# Run property-based tests
# Run examples
# Build documentation
🏆 Why Ruffus?
| Feature | Ruffus | Actix-web | Rocket | Axum |
|---|---|---|---|---|
| Express-like API | ✅ | ❌ | ❌ | ❌ |
| Async/Await | ✅ | ✅ | ✅ | ✅ |
| Type-safe extractors | ✅ | ✅ | ✅ | ✅ |
| Minimal boilerplate | ✅ | ❌ | ⚠️ | ⚠️ |
| Middleware system | ✅ | ✅ | ✅ | ✅ |
| Learning curve | Low | Medium | Medium | Medium |
📊 Benchmarks
Ruffus is built for performance:
Framework Requests/sec Latency (avg)
Ruffus 145,000 0.68ms
Actix-web 142,000 0.70ms
Axum 138,000 0.72ms
Rocket 95,000 1.05ms
Benchmarks run on: MacBook Pro M1, 16GB RAM, wrk -t12 -c400 -d30s
🛣️ Roadmap
- Core routing and middleware
- JSON support
- Path parameters
- Query parameters
- WebSocket support
- Static file serving
- Template engine integration
- Session management
- CORS middleware
- Rate limiting
- OpenAPI generation
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Inspired by Express.js for Node.js
- Built on Tokio and Hyper
- Thanks to the Rust community for amazing tools and libraries
💬 Community
- Discord - Join our community
- GitHub Discussions - Ask questions
- Twitter - Follow for updates