summaryrefslogtreecommitdiff
path: root/angelsharkd/src/routes/extensions/mod.rs
diff options
context:
space:
mode:
authorCarpenter, Adam (CORP) <adam.carpenter@adp.com>2021-11-26 14:32:11 -0500
committerCarpenter, Adam (CORP) <adam.carpenter@adp.com>2021-11-26 14:32:11 -0500
commit75ef35829dc57d5b6f04a0c59160fe7584324793 (patch)
treeb3a8dc76c907df228634daa604631717ea64ce29 /angelsharkd/src/routes/extensions/mod.rs
parent03af9488f7d7fea69c779b1d9263f34841dfad37 (diff)
downloadaltruistic-angelshark-75ef35829dc57d5b6f04a0c59160fe7584324793.tar.xz
altruistic-angelshark-75ef35829dc57d5b6f04a0c59160fe7584324793.zip
feat: basic extension loader module and two scaffolded, unimplemented extensions
Diffstat (limited to 'angelsharkd/src/routes/extensions/mod.rs')
-rw-r--r--angelsharkd/src/routes/extensions/mod.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/angelsharkd/src/routes/extensions/mod.rs b/angelsharkd/src/routes/extensions/mod.rs
new file mode 100644
index 0000000..5dac1cf
--- /dev/null
+++ b/angelsharkd/src/routes/extensions/mod.rs
@@ -0,0 +1,26 @@
+use crate::config::Config;
+use warp::{path, Filter, Rejection, Reply};
+
+#[cfg(feature = "simple_deprov")]
+mod simple_deprov;
+#[cfg(feature = "simple_search")]
+mod simple_search;
+
+pub fn filter(config: &Config) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
+ // Note: this next line deals with the common edge case of having no
+ // extensions loaded with feature flags. It ensures that the the type
+ // checking is right when the return `.and()` is called below.
+ let filters = default().or(default());
+
+ #[cfg(feature = "simple_search")]
+ let filters = filters.or(simple_search::filter());
+
+ #[cfg(feature = "simple_deprov")]
+ let filters = filters.or(simple_deprov::filter());
+
+ path("extensions").and(filters)
+}
+
+fn default() -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone {
+ warp::path::end().map(|| "Angelshark extension route index. Enable extensions with feature switches and access them at `/extensions/<feature>`.")
+}