lmrc-http-common 0.3.16

Common HTTP utilities and patterns for LMRC Stack applications
Documentation
//! # lmrc-http-common
//!
//! Common HTTP utilities and patterns for LMRC Stack applications.
//!
//! This library provides reusable components for building Axum-based HTTP services:
//! - Standard error types and response wrappers
//! - Reusable middleware (CORS, logging, tracing)
//! - Authentication utilities (JWT, session management, password hashing)
//! - Configuration management (server, database)
//! - Health check framework
//! - Validated request extractors
//! - Server bootstrap utilities
//!
//! ## Features
//!
//! - `auth` (default): Enable authentication utilities (JWT, bcrypt, sessions)
//! - `validation` (default): Enable request validation helpers
//! - `server`: Enable server bootstrap utilities (tracing-subscriber, dotenvy)
//!
//! ## Example
//!
//! ```rust
//! use lmrc_http_common::{
//!     error::{HttpError, HttpResult},
//!     response::SuccessResponse,
//! };
//! use axum::{Json, response::IntoResponse};
//!
//! async fn handler() -> HttpResult<impl IntoResponse> {
//!     let data = vec!["item1", "item2"];
//!     Ok(SuccessResponse::new(data))
//! }
//! ```
//!
//! ## Quick Start Server
//!
//! ```rust,no_run
//! # #[cfg(feature = "server")]
//! # {
//! use axum::{Router, routing::get};
//! use lmrc_http_common::server::quick_start;
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//!     let router = Router::new().route("/health", get(|| async { "OK" }));
//!     quick_start("myapp", router, 8080).await?;
//!     Ok(())
//! }
//! # }
//! ```

pub mod config;
pub mod error;
pub mod health;
pub mod response;
pub mod middleware;

#[cfg(feature = "auth")]
pub mod auth;

#[cfg(feature = "validation")]
pub mod extractors;

#[cfg(feature = "server")]
pub mod server;

// Re-export commonly used types
pub use error::{ErrorResponse, HttpError, HttpResult};
pub use response::{
    CreatedResponse, EmptyResponse, PaginatedResponse, PaginationMeta, SuccessResponse,
};
pub use config::{ConfigLoader, ServerConfig, DatabaseConfig, ConfigError, ConfigResult};
pub use health::{HealthStatus, HealthCheck, HealthChecker, Status, CheckResult};

#[cfg(feature = "validation")]
pub use extractors::{ValidatedJson, ValidatedQuery};