๐ฅ Ignitia
A blazing fast, lightweight web framework for Rust that ignites your development journey.
Embodies the spirit of Aarambh (new beginnings) - the spark that ignites your web development journey
Built with โค๏ธ by Aarambh Dev Hub
โก Why Ignitia?
Ignitia embodies the spirit of Aarambh (new beginnings) - the spark that ignites your web development journey. Built for developers who demand speed, simplicity, and power with modern protocol support.
- ๐ Multi-Protocol: HTTP/1.1, HTTP/2, and HTTPS with automatic protocol negotiation
- ๐ TLS/HTTPS: Built-in TLS support with ALPN and self-signed certificates for development
- ๐ชถ Lightweight: Minimal overhead, maximum efficiency
- ๐ฅ Powerful: Advanced routing, middleware, and WebSocket support
- โก Energetic: Modern APIs that energize your development
- ๐ฏ Developer-First: Clean, intuitive, and productive
- ๐ก๏ธ Secure: Built-in security features and best practices
- ๐ช Cookie Management: Full-featured cookie handling with security attributes
- ๐ WebSocket Ready: First-class WebSocket support with optimized performance
๐ Table of Contents
- Installation
- Quick Start
- Core Features
- HTTP/2 & HTTPS
- WebSocket Support
- Routing
- Middleware
- CORS Configuration
- Cookie Management
- Authentication
- Examples
- Performance
- API Reference
- Contributing
๐ ๏ธ Installation
Add Ignitia to your Cargo.toml:
[dependencies]
ignitia = { version = "0.1.8", features = ["tls", "websocket", "self-signed"] }
tokio = { version = "1.40", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tracing-subscriber = "0.3"
Feature Flags
tls: Enables HTTPS/TLS support with certificate management and ALPNwebsocket: Enables WebSocket protocol support with connection managementself-signed: Enables self-signed certificate generation (development only)
๐ Quick Start
Basic HTTP/2 + HTTPS Server
use ;
use ;
async
async
async
๐ฅ Core Features
๐ HTTP/2 & HTTPS Support
Ignitia provides comprehensive support for modern HTTP protocols with automatic negotiation:
Production HTTPS Configuration
use ;
let router = new
.get;
// Production TLS setup
let tls_config = new
.with_alpn_protocols // HTTP/2 priority
.tls_versions
.enable_client_cert_verification;
new
.with_tls?
.ignitia
.await
HTTP to HTTPS Redirect
// Automatic redirect from HTTP to HTTPS
new
.redirect_to_https
.ignitia
.await
H2C (HTTP/2 Cleartext) Support
let config = ServerConfig ;
// Test with: curl --http2-prior-knowledge http://localhost:8080/
๐ Advanced WebSocket Support
First-class WebSocket implementation with optimized performance:
use ;
use ;
let router = new
// Simple echo server
.websocket
// Advanced JSON chat
.websocket
// Batch message processing
.websocket;
๐ก๏ธ Advanced CORS Configuration
Comprehensive CORS middleware with flexible origin matching:
use ;
// Development CORS (permissive)
let dev_cors = permissive;
// Production CORS with specific origins
let prod_cors = new
.allowed_origins
.allowed_methods
.allowed_headers
.expose_headers
.allow_credentials
.max_age // 24 hours
.build?;
// Regex-based origin matching
let regex_cors = new
.allowed_origin_regex // All subdomains
.build?;
let router = new
.middleware
.get;
๐จ Enhanced Error Handling
Comprehensive error handling with custom error types and responses:
use ;
// Define domain-specific errors
define_error!
// Custom error handler middleware
let error_middleware = new
.with_details // Detailed errors in debug mode
.with_json_format
.with_logging
.with_error_log_threshold; // Log 5xx as errors, 4xx as warnings
let router = new
.middleware
.get;
async
๐ฃ๏ธ Advanced Routing
Path Parameter Extraction with Types
use Deserialize;
async
// Supports: /users/123/posts/abc-def
let router = new
.get;
Wildcard Routes
// Wildcard routing for file serving
async
let router = new
.get; // Matches /static/css/style.css, etc.
Nested Routers
// API v1 routes
let api_v1 = new
.get
.post
.get;
// API v2 routes
let api_v2 = new
.get
.post;
// Main router with nested subrouters
let router = new
.get
.nest
.nest;
๐ง Comprehensive Middleware
Built-in Middleware Stack
use ;
let router = new
// Request logging with HTTP version info
.middleware
// Advanced CORS configuration
.middleware
// Path-based authentication
.middleware
// Enhanced error handling
.middleware
.get
.get // Protected
.get; // Protected
Custom Middleware Implementation
use ;
๐ช Advanced Cookie Management
Secure Session Management
use ;
// Production-ready session cookie
let create_session_cookie = ;
async
async
// Protected route using cookies
async
โก Performance & Benchmarks
Real-World Performance Results
Framework Comparison (Higher is Better)
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ Framework โ Avg RPS โ Peak RPS โ Avg Latency โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ ๐ฅ Ignitia โ 19,285.4 โ 25,050.5 โ 12.96ms โ
โ Actix Web โ 18,816.8 โ 24,981.7 โ 13.26ms โ
โ Axum โ 6,797.1 โ 9,753.9 โ 23.85ms โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
HTTP/2 vs HTTP/1.1 Performance (Ignitia)
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ Protocol โ Avg RPS โ Concurrent โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ HTTP/2 โ 21,450.2 โ 1000 โ
โ HTTP/1.1 โ 19,285.4 โ 1000 โ
โ H2C โ 20,892.1 โ 1000 โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
Performance Features
// Zero-copy request processing
async
// HTTP/2 server push (when supported by client)
async
๐ Comprehensive Examples
๐ข Production REST API
use ;
use ;
use HashMap;
use ;
type UserStore = ;
async
async
async
async
async
๐ API Reference
Router Methods
| Method | Description | Example |
|---|---|---|
Router::new() |
Create new router | Router::new() |
.get(path, handler) |
Add GET route | .get("/users/:id", get_user) |
.post(path, handler) |
Add POST route | .post("/users", create_user) |
.put(path, handler) |
Add PUT route | .put("/users/:id", update_user) |
.delete(path, handler) |
Add DELETE route | .delete("/users/:id", delete_user) |
.websocket(path, handler) |
Add WebSocket route | .websocket("/ws", ws_handler) |
.middleware(middleware) |
Add middleware | .middleware(LoggerMiddleware) |
.nest(path, router) |
Nest router | .nest("/api/v1", api_router) |
Server Configuration
| Method | Description | Example |
|---|---|---|
Server::new(router, addr) |
Create server | Server::new(router, addr) |
.with_config(config) |
Set server config | .with_config(server_config) |
.with_tls(tls_config) |
Enable HTTPS | .with_tls(tls_config) |
.redirect_to_https(port) |
HTTP redirect | .redirect_to_https(443) |
.ignitia() |
Start server | .ignitia().await |
Extractors
| Extractor | Type | Example |
|---|---|---|
Path<T> |
URL parameters | Path(user_id): Path<String> |
Query<T> |
Query parameters | Query(params): Query<SearchParams> |
Json<T> |
JSON body | Json(user): Json<User> |
Body |
Raw body | Body(body): Body |
Headers |
Request headers | headers: Headers |
Cookies |
Request cookies | cookies: Cookies |
Extension<T> |
Shared state | Extension(state): Extension<AppState> |
๐งช Testing
# Run all tests
cargo test
# Test with features
cargo test --features "tls,websocket"
# Integration tests
cargo test --test integration
# Performance benchmarks
cargo bench
Testing Your API
# HTTP/1.1
curl -v http://localhost:8080/api/users
# HTTP/2
curl -v --http2-prior-knowledge http://localhost:8080/api/users
# HTTPS/HTTP2
curl -v --http2 https://localhost:8443/api/users
# WebSocket
websocat ws://localhost:8080/ws/echo
๐ค Contributing
We welcome contributions! Here's how you can help:
Development Setup
# Clone repository
git clone https://github.com/AarambhDevHub/ignitia.git
cd ignitia
# Install dependencies
cargo build
# Run tests
cargo test --all-features
# Run examples
cargo run --example basic_server
cargo run --example websocket_chat
Guidelines
- Code Quality: Run
cargo fmtandcargo clippy - Tests: Add tests for new features
- Documentation: Update docs and examples
- Performance: Benchmark performance-critical changes
๐ Changelog
v0.1.8 - Protocol Master Release ๐
๐ New Features
- โ HTTP/2 Support: Full HTTP/2 implementation with ALPN negotiation
- โ TLS/HTTPS: Comprehensive TLS support with certificate management
- โ H2C Support: HTTP/2 cleartext for development and testing
- โ Self-Signed Certificates: Automatic cert generation for development
- โ Advanced CORS: Regex origin matching and credential support
- โ Enhanced WebSocket: Optimized WebSocket with batch processing
- โ Custom Error Handling: Detailed error types and responses
- โ Protocol Detection: Automatic HTTP version negotiation
๐ Performance
- โ 19,285+ RPS: Leading performance in Rust ecosystem
- โ Zero-Copy: Efficient request/response handling
- โ Connection Pooling: Optimized connection management
- โ HTTP/2 Multiplexing: Multiple streams over single connection
๐ Security
- โ TLS 1.2/1.3: Modern TLS support with ALPN
- โ Secure Cookies: Full security attribute support
- โ CORS Protection: Advanced cross-origin controls
- โ Path Traversal Protection: Secure file serving
๐ License
MIT License - see LICENSE for details.
โ Support
If you find Ignitia helpful, consider:
๐ Get Started Today
# Create new project
cargo new my-ignitia-app && cd my-ignitia-app
# Add Ignitia with all features
echo 'ignitia = { version = "0.1.8", features = ["tls", "websocket", "self-signed"] }' >> Cargo.toml
# Create your first HTTP/2 + WebSocket app
cargo run
Join thousands of developers building the future with Ignitia
๐ฅ Ignitia. Build Fast. Scale Further. ๐ฅ
Built with โค๏ธ by Aarambh Dev Hub
Where every line of code ignites possibilities.