chore: home filter

This commit is contained in:
Jesús Pérez Lorenzo 2021-10-12 11:11:37 +01:00
parent 9f77102f3a
commit 836ab03ccf

View File

@ -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<Extract = impl warp::Reply, Error = warp::Rejection> + 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<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
) -> BoxedFilter<(impl warp::Reply,)> {
let prfx = self.prfx.to_owned();
warp::path(path)
.and(warp::get())
// .and(warp::query::<KloudQueryConfigFilters>())
.and(headers_cloned())
.and(method())
// .and_then(user_authentication)
// .and(warp::header::optional::<String>("authorization"))
// .and(warp::header::optional::<String>("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(