rusty-gasket 0.1.2

A plugin-based Rust framework for backend HTTP services
//! Rusty Gasket — a plugin-based Rust API framework.
//!
//! Provides a lifecycle-driven plugin system, middleware pipeline,
//! configuration management, structured error handling, observability,
//! health checks, and rate limiting for building production HTTP APIs.
//!
//! Most users should import `rusty_gasket::prelude::*` to get the
//! commonly needed types and traits.

#![cfg_attr(docsrs, feature(doc_auto_cfg))]

use std::future::Future;
use std::pin::Pin;

// Self-reference so that proc macro generated code using `::rusty_gasket::`
// resolves correctly both inside this crate and in downstream crates.
#[allow(unused_extern_crates)]
extern crate self as rusty_gasket;

#[cfg(feature = "cache")]
#[cfg_attr(docsrs, doc(cfg(feature = "cache")))]
pub mod cache;
pub mod config;
pub mod error;
pub mod extract;
pub mod health;
pub mod jobs;
pub mod middleware;
pub mod observability;
#[cfg(feature = "openapi")]
#[cfg_attr(docsrs, doc(cfg(feature = "openapi")))]
pub mod openapi;
#[cfg(feature = "otlp")]
#[cfg_attr(docsrs, doc(cfg(feature = "otlp")))]
pub mod otel;
pub mod pipeline;
pub mod plugin;
pub mod presets;
pub mod rate_limit;
pub mod server;

// Optional batteries — folded-in, feature-gated modules.
#[cfg(feature = "auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
pub mod auth;
#[cfg(feature = "aws")]
#[cfg_attr(docsrs, doc(cfg(feature = "aws")))]
pub mod aws;
#[cfg(feature = "db")]
#[cfg_attr(docsrs, doc(cfg(feature = "db")))]
pub mod db;
#[cfg(feature = "dynamodb")]
#[cfg_attr(docsrs, doc(cfg(feature = "dynamodb")))]
pub mod dynamodb;
#[cfg(feature = "templates")]
#[cfg_attr(docsrs, doc(cfg(feature = "templates")))]
pub mod templates;
#[cfg(feature = "testing")]
#[cfg_attr(docsrs, doc(cfg(feature = "testing")))]
pub mod testing;

/// Re-exports of the most commonly used types and traits.
///
/// Import `use rusty_gasket::prelude::*` to get everything you need
/// for implementing plugins and building an application.
pub mod prelude {
    pub use crate::BoxError;
    #[cfg(feature = "cache")]
    pub use crate::cache::{
        CacheAlgorithm, CacheBackendKind, CacheConfig, CacheError, CacheKey, CacheResult, CacheTtl,
        MemcachedCacheConfig, MemoryBudget, ObjectCache, RedisCacheConfig, ResponseCachePolicy,
        ResponseCacheScope, cached_get,
    };
    pub use crate::config::{AppConfig, AppConfigDefinition, Environment};
    pub use crate::error::{ApiError, ErrorResponse, ProblemDetails};
    pub use crate::extract::{
        Context, IdempotencyKey, JsonBody, Pagination, PathParams, QueryParams, RequestContext,
        Validate, Validated, ValidationError, ValidationErrors, seconds,
    };
    pub use crate::health::{HealthContributor, HealthPlugin};
    pub use crate::jobs::SchedulerPlugin;
    pub use crate::middleware::{
        CompressionPlugin, CorsPlugin, SecureHeadersPlugin, TimeoutPlugin,
    };
    pub use crate::pipeline::MiddlewareSlot;
    pub use crate::plugin::{
        BoxPlugin, GasketApp, GasketAppBuilder, InitContext, LayerContext, Plugin, PluginHandle,
        PluginOrdering, PrepareContext, RouteContext, RouteGroup, RouterTransform, TaggedLayer,
        TaggedRoute,
    };
    #[cfg(feature = "cache")]
    pub use crate::route_cache_get;
    pub use crate::server::ServerPlugin;

    pub use axum::{
        Router,
        routing::{delete, get, patch, post, put},
    };
}

/// Build-time metadata (git SHA, build date, rustc version, etc.)
/// generated by the `built` crate during compilation. Private to the
/// crate; consumers read it through the public health endpoint.
mod built_info {
    include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

/// Convenience alias for a boxed, thread-safe error type.
pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;

/// Shorthand for boxed futures at dyn-compatible framework boundaries.
///
/// Most application authors should not need this directly; implement the
/// public extension traits with normal `async fn` methods. The framework
/// still uses boxed futures internally where extension points are stored
/// behind `dyn` trait objects.
pub type BoxFuture<'ctx, T> = Pin<Box<dyn Future<Output = T> + Send + 'ctx>>;