| Crates.io | ignitia |
| lib.rs | ignitia |
| version | 0.2.1 |
| created_at | 2025-08-29 10:27:42.250597+00 |
| updated_at | 2025-09-21 03:25:58.550907+00 |
| description | A blazing fast, lightweight web framework for Rust that ignites your development journey |
| homepage | https://github.com/AarambhDevHub/ignitia |
| repository | https://github.com/AarambhDevHub/ignitia |
| max_upload_size | |
| id | 1815670 |
| size | 1,324,927 |
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
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.
Ignitia comes with comprehensive documentation to help you get started quickly and master advanced features:
doc/
โโโ ๐ README.md # This file - overview and quick start
โโโ ๐ QUICK_START.md # 5-minute setup guide
โโโ ๐ INSTALLATION.md # Detailed installation instructions
โโโ ๐ ROUTING_GUIDE.md # Advanced routing patterns
โโโ ๐ MIDDLEWARE_GUIDE.md # Custom middleware development
โโโ ๐ ERROR_HANDLING.md # Error handling patterns
โโโ ๐ EXTRACTORS.md # Type-safe request extraction
โโโ ๐ WEB_SOCKETS.md # WebSocket implementation guide
โโโ ๐ FILE_UPLOADS.md # File upload and multipart handling
โโโ ๐ SERVER_CONFIG.md # Server configuration options
โโโ ๐ SECURITY.md # Security best practices
โโโ ๐ API_REFERENCE.md # API reference documentation
โโโ ๐ REQUESTS.md # Request handling patterns
โโโ ๐ RESPONSES.md # Response handling patterns
โโโ ๐ STATIC_FILES.md # Serving static files
โโโ ๐ MIGRATION.md # Migration from other frameworks
โโโ ๐ CONTRIBUTING.md # How to contribute
โโโ ๐ CHANGELOG.md # Version history
โโโ ๐ EXAMPLES.md # Comprehensive examples
๐ Quick Links:
Add Ignitia to your Cargo.toml:
[dependencies]
ignitia = { version = "0.2.1", 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"
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)use ignitia::{
Router, Server, Response, Result, State,
handler::extractor::{Path, Query, Json, Form, Multipart},
};
use serde::{Deserialize, Serialize};
#[derive(Clone)]
struct AppState {
name: String,
version: String,
upload_dir: String,
}
#[derive(Deserialize)]
struct UserForm {
name: String,
email: String,
}
#[tokio::main]
async fn main() -> Result<()> {
// Initialize logging
tracing_subscriber::init();
// Create shared application state
let app_state = AppState {
name: "My Ignitia App".to_string(),
version: "1.0.0".to_string(),
upload_dir: "./uploads".to_string(),
};
let router = Router::new()
.get("/", home)
.get("/users/:id", get_user)
.post("/api/data", create_data)
.post("/forms/user", handle_form)
.post("/upload", handle_file_upload) // File upload endpoint
.post("/upload/profile", handle_profile_upload) // Profile with file
.get("/health", health_check)
.state(app_state); // Add shared state
// Start high-performance server
Server::new("127.0.0.1:8080")
.run(router)
.await
}
// Handler with state access
async fn home(State(state): State<AppState>) -> Result<Response> {
Response::html(format!(
"<h1>๐ฅ Welcome to {}!</h1><p>Version: {}</p>",
state.name, state.version
))
}
// Path parameter extraction
async fn get_user(Path(user_id): Path<String>) -> Result<Response> {
Response::json(serde_json::json!({
"user_id": user_id,
"name": "John Doe",
"framework": "Ignitia"
}))
}
// JSON body handling
#[derive(Deserialize, Serialize)]
struct ApiData {
message: String,
timestamp: chrono::DateTime<chrono::Utc>,
}
async fn create_data(Json(data): Json<ApiData>) -> Result<Response> {
Response::json(serde_json::json!({
"status": "created",
"data": data,
"received_at": chrono::Utc::now()
}))
}
// Form data handling
async fn handle_form(Form(form): Form<UserForm>) -> Result<Response> {
Response::json(serde_json::json!({
"message": "Form received",
"user": {
"name": form.name,
"email": form.email
}
}))
}
// File upload handling
async fn handle_file_upload(
State(state): State<AppState>,
mut multipart: Multipart,
) -> Result<Response> {
let mut uploaded_files = Vec::new();
while let Some(field) = multipart.next_field().await? {
if let Some(filename) = field.file_name() {
let content_type = field.content_type().unwrap_or("application/octet-stream");
let data = field.bytes().await?;
// Save file
let file_path = format!("{}/{}", state.upload_dir, filename);
tokio::fs::write(&file_path, data).await?;
uploaded_files.push(serde_json::json!({
"filename": filename,
"size": data.len(),
"content_type": content_type,
"path": file_path
}));
}
}
Response::json(serde_json::json!({
"message": "Files uploaded successfully",
"files": uploaded_files
}))
}
// Profile with file upload
#[derive(Deserialize)]
struct ProfileForm {
name: String,
bio: String,
age: Option<u32>,
}
async fn handle_profile_upload(
State(state): State<AppState>,
mut multipart: Multipart,
) -> Result<Response> {
let mut profile_data = None;
let mut avatar_file = None;
while let Some(field) = multipart.next_field().await? {
let field_name = field.name().unwrap_or("unknown");
if let Some(filename) = field.file_name() {
// Handle file field
let data = field.bytes().await?;
let file_path = format!("{}/avatars/{}", state.upload_dir, filename);
tokio::fs::write(&file_path, &data).await?;
avatar_file = Some(serde_json::json!({
"filename": filename,
"size": data.len(),
"path": file_path
}));
} else {
// Handle text field
let value = field.text().await?;
match field_name {
"name" => profile_data = Some(ProfileForm {
name: value,
bio: "".to_string(),
age: None
}),
_ => {} // Handle other fields
}
}
}
Response::json(serde_json::json!({
"message": "Profile updated successfully",
"profile": profile_data,
"avatar": avatar_file
}))
}
// Health check with state
async fn health_check(State(state): State<AppState>) -> Result<Response> {
Response::json(serde_json::json!({
"status": "healthy",
"app": state.name,
"version": state.version,
"timestamp": chrono::Utc::now()
}))
}
Ignitia delivers exceptional performance that outperforms popular frameworks:
๐ COMPREHENSIVE BENCHMARK RESULTS
--------------------------------------------------
๐ฅ Ignitia Framework
Average RPS: 18,367.7 (+185% vs Axum)
Peak RPS: 24,014.1 (Near Actix-web peak)
Average Response Time: 13.34ms (45% faster than Axum)
Best Response Time: 0.14ms (48% faster than Axum)
Failed Requests: 0 (100% reliability)
๐ฅ Actix-web
Average RPS: 17,792.7
Peak RPS: 24,296.3
Average Response Time: 14.06ms
Best Response Time: 0.18ms
Failed Requests: 0
๐ฅ Axum
Average RPS: 6,437.3
Peak RPS: 9,331.4
Average Response Time: 24.42ms
Best Response Time: 0.27ms
Failed Requests: 0
// Zero-copy request processing
async fn high_performance_handler(Body(body): Body) -> Result<Response> {
// Process large payloads efficiently without copying
let processed = process_large_data(&body).await?;
Response::binary(processed) // Zero-copy response
}
// HTTP/2 multiplexing advantage
let config = ServerConfig {
http2: Http2Config {
enabled: true,
max_concurrent_streams: Some(1000),
initial_connection_window_size: Some(1024 * 1024), // 1MB
adaptive_window: true,
..Default::default()
},
..Default::default()
};
ArcSwapArc<T> and RwLock for shared stateIgnitia provides comprehensive support for modern HTTP protocols with automatic negotiation:
use ignitia::{Server, Router, TlsConfig, TlsVersion};
let router = Router::new()
.get("/", || async { Response::text("Secure HTTPS with HTTP/2!") });
// Production TLS setup
let tls_config = TlsConfig::new("production.crt", "production.key")
.with_alpn_protocols(vec!["h2", "http/1.1"]) // HTTP/2 priority
.tls_versions(TlsVersion::TlsV12, TlsVersion::TlsV13)
.enable_client_cert_verification();
Server::new("0.0.0.0:443")
.tls(tls_config)
.run(router)
.await
// Quick HTTPS setup for development
Server::new("127.0.0.1:8443")
.self_signed_cert("localhost") // โ ๏ธ Development only!
.run(router)
.await
let config = ServerConfig {
http2: Http2Config {
enabled: true,
enable_prior_knowledge: true, // Enables H2C
..Default::default()
},
..Default::default()
};
// Test with: curl --http2-prior-knowledge http://localhost:8080/
First-class WebSocket implementation with optimized performance:
use ignitia::{websocket_handler, websocket_message_handler, Message, WebSocketConnection};
use serde::{Deserialize, Serialize};
let router = Router::new()
// Simple echo server
.websocket("/ws/echo", websocket_handler(|ws: WebSocketConnection| async move {
while let Some(message) = ws.recv().await {
match message {
Message::Text(text) => {
ws.send_text(format!("Echo: {}", text)).await?;
}
Message::Binary(data) => {
ws.send_bytes(data).await?;
}
Message::Close(_) => break,
_ => {}
}
}
Ok(())
}))
// Advanced JSON chat
.websocket("/ws/chat", websocket_message_handler(|ws, message| async move {
if let Message::Text(text) = message {
#[derive(Deserialize, Serialize)]
struct ChatMessage {
user: String,
message: String,
room: String,
}
if let Ok(chat_msg) = serde_json::from_str::<ChatMessage>(&text) {
let response = serde_json::json!({
"user": chat_msg.user,
"message": chat_msg.message,
"room": chat_msg.room,
"timestamp": chrono::Utc::now(),
"server": "ignitia"
});
ws.send_json(&response).await?;
}
}
Ok(())
}));
Ignitia provides powerful, type-safe extractors for handling various parts of HTTP requests:
use ignitia::{Path, Query, Json, Form, Body, Headers, Cookies, State, Multipart};
use serde::Deserialize;
#[derive(Deserialize)]
struct UserParams {
user_id: u32,
post_id: String,
}
#[derive(Deserialize)]
struct SearchQuery {
q: String,
page: Option<u32>,
per_page: Option<u32>,
}
#[derive(Deserialize)]
struct CreateUser {
name: String,
email: String,
age: Option<u32>,
}
#[derive(Deserialize)]
struct LoginForm {
username: String,
password: String,
remember_me: Option<bool>,
}
// Multiple extractors in one handler
async fn advanced_handler(
Path(params): Path<UserParams>, // URL parameters
Query(search): Query<SearchQuery>, // Query string
Json(user_data): Json<CreateUser>, // JSON body
Form(login): Form<LoginForm>, // Form data
Body(raw_body): Body, // Raw request body
headers: Headers, // All headers
cookies: Cookies, // All cookies
State(app_state): State<AppState>, // Shared state
mut multipart: Multipart, // Multipart data
) -> Result<Response> {
// Access all extracted data
println!("User ID: {}", params.user_id);
println!("Search query: {}", search.q);
println!("New user: {}", user_data.name);
println!("Login attempt: {}", login.username);
// Process multipart if present
while let Some(field) = multipart.next_field().await? {
if let Some(filename) = field.file_name() {
let data = field.bytes().await?;
println!("Received file: {} ({} bytes)", filename, data.len());
}
}
Response::json(serde_json::json!({
"message": "All extractors working!",
"user_agent": headers.get("user-agent")
}))
}
Ignitia provides powerful state management for sharing data across handlers:
use ignitia::{Router, State};
use std::sync::Arc;
#[derive(Clone)]
struct AppState {
db_pool: Arc<DatabasePool>,
config: AppConfig,
metrics: Arc<MetricsCollector>,
}
#[derive(Clone)]
struct AppConfig {
api_url: String,
max_connections: u32,
debug: bool,
}
async fn main() -> Result<()> {
let app_state = AppState {
db_pool: Arc::new(create_database_pool().await?),
config: AppConfig {
api_url: "https://api.example.com".to_string(),
max_connections: 100,
debug: cfg!(debug_assertions),
},
metrics: Arc::new(MetricsCollector::new()),
};
let router = Router::new()
.get("/users", list_users)
.post("/users", create_user)
.get("/metrics", get_metrics)
.state(app_state); // Add state to router
Server::new("127.0.0.1:8080")
.run(router)
.await
}
// Handlers can access state
async fn list_users(State(state): State<AppState>) -> Result<Response> {
let users = state.db_pool.get_all_users().await?;
state.metrics.increment("users_listed");
Response::json(users)
}
async fn create_user(
State(state): State<AppState>,
Json(user_data): Json<CreateUserRequest>,
) -> Result<Response> {
let user = state.db_pool.create_user(user_data).await?;
state.metrics.increment("users_created");
Response::json(user).status(201)
}
// Multiple state types
async fn get_metrics(
State(app_state): State<AppState>,
State(cache): State<RedisCache>, // Multiple state types
) -> Result<Response> {
let metrics = app_state.metrics.get_all();
cache.store("last_metrics", &metrics, 300).await?;
Response::json(metrics)
}
# Run all tests
cargo test
# Test with features
cargo test --features "tls,websocket,multipart"
# Integration tests
cargo test --test integration
# Performance benchmarks
cargo bench
# 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
# Form data
curl -X POST -d "name=John&email=john@example.com" http://localhost:8080/forms/user
# File upload
curl -X POST -F "file=@image.jpg" http://localhost:8080/upload
# Multiple file upload
curl -X POST -F "files=@file1.pdf" -F "files=@file2.jpg" http://localhost:8080/upload/multiple
# Mixed form with file
curl -X POST \
-F "name=John Doe" \
-F "email=john@example.com" \
-F "avatar=@profile.jpg" \
http://localhost:8080/users/123/profile
We welcome contributions! Here's how you can help:
# 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
cargo run --example file_upload
cargo fmt and cargo clippyState<T>Form<T>Multipart extractorMIT License - see LICENSE for details.
If you find Ignitia helpful, consider supporting the project:
# Create new project
cargo new my-ignitia-app && cd my-ignitia-app
# Add Ignitia with all features
echo 'ignitia = { version = "0.2.1", features = ["tls", "websocket", "self-signed"] }' >> Cargo.toml
# Create your first high-performance app
cargo run
Join thousands of developers building the future with Ignitia
Built with โค๏ธ by Aarambh Dev Hub
Where every line of code ignites possibilities.