From d4f5bbce4541a5997e609904230799fe606b87b9 Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Sat, 9 Oct 2021 00:59:11 +0100 Subject: [PATCH] chore: add filters for apps_services & cleanup --- src/filters.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/filters.rs b/src/filters.rs index e2817a1..64ad11f 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -116,12 +116,14 @@ impl CollFilters { let provision_path: &'static str = Box::leak(format!("{}provision",&self.prfx).into_boxed_str()); let status_path: &'static str = Box::leak(format!("{}status",&self.prfx).into_boxed_str()); let liveness_path: &'static str = Box::leak(format!("{}liveness",&self.prfx).into_boxed_str()); + let apps_path: &'static str = Box::leak(format!("{}apps",&self.prfx).into_boxed_str()); self.config(db.clone(),cloud.clone(),config_path,cors.clone()) .or(self.defs(db.clone(),defs_path,cors.clone())) .or(self.langs(db.clone(),lang_path,cors.clone())) .or(self.provision(db.clone(),cloud.clone(),provision_path,cors.clone())) .or(self.status(db.clone(),cloud.clone(),status_path,cors.clone())) .or(self.liveness(db.clone(),cloud.clone(),liveness_path,cors.clone())) + .or(self.apps(db.clone(),cloud.clone(),apps_path,cors.clone())) .boxed() } /// GET /ta?offset=3&limit=5 @@ -399,6 +401,31 @@ impl CollFilters { .and_then(handlers::h_config::liveness) .with(cors) .boxed() + } + /// GET /status?offset=3&limit=5 + pub fn apps( + &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_config::apps) + .with(cors) + .boxed() } fn with_db(&self, db: DataDBs) -> impl Filter + Clone { warp::any().map(move || db.clone())