kegani 0.1.0

A developer-friendly, ergonomic, production-ready Rust web framework
Documentation
//! Kegani binary entry point
//!
//! Example application demonstrating Kegani framework features.

use actix_web::{web, HttpResponse};
use kegani::prelude::*;

/// Application state
#[derive(Clone)]
struct AppState {
    pub name: String,
}

/// Simple hello endpoint
#[get("/api/hello")]
async fn hello() -> &'static str {
    "Hello from Kegani!"
}

/// Echo endpoint
#[post("/api/echo")]
async fn echo(body: String) -> HttpResponse {
    HttpResponse::Ok()
        .content_type("application/json")
        .body(body)
}

/// User endpoint example
#[get("/api/users/{id}")]
async fn get_user(Path(id): Path<String>) -> HttpResponse {
    let user = serde_json::json!({
        "id": id,
        "name": format!("User {}", id),
        "email": format!("user{}@example.com", id)
    });

    HttpResponse::Ok()
        .content_type("application/json")
        .json(user)
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    // Initialize logging
    tracing_subscriber::fmt()
        .with_env_filter(
            tracing_subscriber::EnvFilter::try_from_default_env()
                .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
        )
        .init();

    tracing::info!("Starting Kegani server...");
    tracing::info!("📚 API Docs: http://127.0.0.1:30080/swagger-ui");
    tracing::info!("📖 ReDoc: http://127.0.0.1:30080/redoc");

    App::new()
        .host("127.0.0.1")
        .port(30080)
        .run()
        .await
}