//! Middleware module

pub use tower_http::{
    cors::CorsLayer,
    trace::TraceLayer,
    services::ServeDir,
};

/// Standard middleware stack for development
pub fn development_middleware() -> tower::ServiceBuilder<
    tower::ServiceBuilder<
        tower::ServiceBuilder<tower::Identity>
    >
> {
    tower::ServiceBuilder::new()
        .layer(TraceLayer::new_for_http())
        .layer(CorsLayer::permissive())
}

/// Standard middleware stack for production
pub fn production_middleware() -> tower::ServiceBuilder<
    tower::ServiceBuilder<
        tower::ServiceBuilder<tower::Identity>
    >
> {
    tower::ServiceBuilder::new()
        .layer(TraceLayer::new_for_http())
        .layer(CorsLayer::new().allow_origin("https://example.com".parse::<axum::http::HeaderValue>().unwrap()))
}