Skip to main content

Crate kegani

Crate kegani 

Source
Expand description

Kegani Framework — A developer-friendly, ergonomic, production-ready Rust web framework

§Core Design

Kegani provides a layered architecture similar to GoFrame:

  • RoutesControllersLogicServiceRepositoryModel
  • Config loaded from YAML + environment variables
  • Lifecycle managed by the Carapace orchestrator

§Quick Start

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

async fn main() -> std::io::Result<()> {
    App::new()
        .port(8080)
        .configure(|cfg| {
            cfg.service(web::scope("/api")
                .route("/health", web::get().to(|| async {
                    HttpResponse::Ok().json(serde_json::json!({ "status": "ok" }))
                }))
            );
        })
        .run()
        .await
}

§Features

  • App builder — Fluent HTTP server configuration with graceful shutdown
  • Route macros#[get], #[post], #[put], #[delete], #[patch]
  • ExtractorsPath<T>, Query<T>, State<T> (Use actix_web::web::Json<T> directly for JSON body extraction)
  • Middleware — Logger, CORS, Tracing, Timeout, SessionCookie
  • Config — YAML + env var override with hot reload
  • Database — sqlx connection pool with migrations
  • Cache — Redis with cache-aside pattern
  • Auth — JWT generation and verification
  • Session — In-memory and Redis-backed session stores
  • Validation — Field-level validators + optional garde declarative validation
  • Metrics — Prometheus-compatible counters, gauges, histograms
  • OpenAPI — Swagger UI + ReDoc auto-served at /api-docs
  • Lifecycle — Carapace Module trait for dependency-ordered startup/shutdown
  • Graceful shutdown — Ctrl+C handling with configurable timeout

Re-exports§

pub use app::App;
pub use error::AppError;
pub use error::Result;
pub use route::Path;
pub use route::Query;
pub use route::State;
pub use controller::Json;
pub use controller::Status;
pub use controller::Response;
pub use controller::EmptyJson;
pub use middleware::Logger;
pub use middleware::Cors;
pub use middleware::Tracing;
pub use middleware::Timeout;
pub use config::Settings;
pub use health::HealthCheck;
pub use metrics::Metrics;
pub use auth::JwtAuth;
pub use auth::JwtConfig;
pub use auth::Claims;
pub use cache::RedisCache;
pub use cache::RedisConfig;
pub use db::DbPool;
pub use db::DbPoolConfig;
pub use service::Service;
pub use service::DependencyContext;
pub use service::ServiceBuilder;
pub use lifecycle::Carapace;
pub use lifecycle::Module;
pub use session::Session;
pub use session::SessionStore;
pub use session::SessionConfig;
pub use session::SessionCookie;
pub use validation::validators::ValidationError;
pub use validation::validators::Validator;
pub use openapi::OpenApiDoc;
pub use openapi::SwaggerUi;
pub use openapi::ReDoc;
pub use client::ClientGenerator;

Modules§

app
Application builder for Kegani web framework
auth
Authentication module for Kegani
cache
Cache module for Kegani
client
Client generator module for Kegani
config
Configuration module for Kegani
controller
Controller module - Request handling and response building
db
Database pool management for Kegani
error
health
Health check module for Kegani
lifecycle
Lifecycle management module for Kegani
metrics
Prometheus metrics module for Kegani
middleware
Middleware module for Kegani
openapi
OpenAPI module for Kegani
prelude
repository
Repository module for Kegani
route
Route module for Kegani
service
Service module for Kegani
session
Session management for Kegani
upload
File upload module for Kegani
validation
Validation module for Kegani
websocket
WebSocket module for Kegani