pub mod request_id;
pub mod logging;
pub use request_id::{RequestIdLayer, add_request_id, RequestId, REQUEST_ID_HEADER};
pub use logging::{LoggingLayer, log_request};
use tower_http::cors::{Any, CorsLayer};
pub fn permissive_cors() -> CorsLayer {
CorsLayer::new()
.allow_origin(Any)
.allow_methods(Any)
.allow_headers(Any)
.allow_credentials(true)
}
pub fn cors_with_origins(origins: Vec<String>) -> CorsLayer {
use tower_http::cors::AllowOrigin;
let origins: Vec<_> = origins
.into_iter()
.filter_map(|o| o.parse().ok())
.collect();
CorsLayer::new()
.allow_origin(AllowOrigin::list(origins))
.allow_methods(Any)
.allow_headers(Any)
.allow_credentials(true)
}