diff --git a/src/filters.rs b/src/filters.rs index 64ad11f..c211e82 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -67,6 +67,18 @@ impl CollFilters { prfx: String::from(prfx), } } + pub fn filters_home( + &self, + db: DataDBs, + cloud: Cloud, + cors: warp::cors::Builder, + path: &str, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let url_path: &'static str = Box::leak(format!("{}",&path).into_boxed_str()); + self.home(db.clone(),cloud.clone(),url_path,cors.clone()) + .boxed() + } pub fn filters_defs( &self, db: DataDBs, @@ -125,6 +137,30 @@ impl CollFilters { .or(self.liveness(db.clone(),cloud.clone(),liveness_path,cors.clone())) .or(self.apps(db.clone(),cloud.clone(),apps_path,cors.clone())) .boxed() + } + pub fn home( + &self, + db: DataDBs, + cloud: Cloud, + path: &'static str, + cors: warp::cors::Builder, + //) -> impl Filter + Clone { + ) -> BoxedFilter<(impl warp::Reply,)> { + let prfx = self.prfx.to_owned(); + warp::path(path) + .and(warp::get()) + // .and(warp::query::()) + .and(headers_cloned()) + .and(method()) + // .and_then(user_authentication) + // .and(warp::header::optional::("authorization")) + // .and(warp::header::optional::("accept-language")) + .and(self.with_db(db)) + .and(warp::any().map(move || cloud.to_owned())) + .and(warp::any().map(move || prfx.to_owned())) + .and_then(handlers::h_home::home) + .with(cors) + .boxed() } /// GET /ta?offset=3&limit=5 pub fn list(