Kegani - Rust Web Framework
A developer-friendly, ergonomic, production-ready Rust web framework built on Actix-web.
Features
- Fast HTTP Server: Built on Actix-web for high performance
- Type-safe Routing: Express/Gin-style route definitions with procedural macros
- Middleware System: Logging, CORS, Tracing, Timeout, Rate Limiting
- Session Management: In-memory session storage
- JWT Authentication: Built-in JWT support with Claims
- Caching: Redis integration
- Metrics: Prometheus-compatible metrics collection
- OpenAPI Support: Swagger UI and ReDoc integration
- Database: SQLx integration with PostgreSQL support
- Repository Pattern: Clean data access layer
- Service Layer: Dependency injection for business logic
Quick Start
use *;
async
Route Macros
use *;
async
async
Response Helpers
use *;
// JSON response
Ok
// Created status
Ok
// Named status codes
Err
// Custom response
new
.status
.header
.json
Middleware
new
.wrap
.wrap
.wrap
.wrap
Modules
| Module | Description |
|---|---|
app |
Application builder |
error |
Unified error handling |
route |
Route extractors (Path, Query, State) |
controller |
Response types (Json, Status, Response) |
middleware |
Logger, Cors, Tracing, Timeout, RateLimit |
config |
Configuration management |
health |
Health check endpoints |
metrics |
Metrics collection |
auth |
JWT authentication |
cache |
Redis caching |
db |
Database connection pool |
repository |
Repository pattern |
service |
Service layer with DI |
openapi |
OpenAPI documentation |
client |
API client generator |
Testing
# Run all tests
# Run performance tests
Performance Benchmarks
- JSON Serialization: 10,000 ops in < 100ms
- HashMap Operations: 100,000 lookups in < 50ms
- UUID Generation: 10,000 ops in < 100ms
Configuration
Load configuration from YAML and environment variables:
let config = load?;
// Override with environment variables
// APP_HOST, APP_PORT, DATABASE_URL, REDIS_URL, LOG_LEVEL
License
MIT OR Apache-2.0