From 3ca7069a4b75c844a622d599e4ba9473aa247821 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Wed, 28 Feb 2024 13:24:32 +0100 Subject: [PATCH] feat: internal backstage features endpoint (#422) Adds an endpoint /internal-backstage/features displaying which features we store per cache key --- server/src/internal_backstage.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/src/internal_backstage.rs b/server/src/internal_backstage.rs index a9c3b918..8b8457c1 100644 --- a/server/src/internal_backstage.rs +++ b/server/src/internal_backstage.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use crate::auth::token_validator::TokenValidator; use crate::http::feature_refresher::FeatureRefresher; use crate::metrics::actix_web_metrics::PrometheusMetricsHandler; @@ -79,6 +81,17 @@ pub async fn tokens( token_validation_status, })) } + +#[get("/features")] +pub async fn features( + features_cache: web::Data>, +) -> EdgeJsonResult> { + let features = features_cache + .iter() + .map(|e| (e.key().clone(), e.value().clone())) + .collect(); + Ok(Json(features)) +} pub fn configure_internal_backstage( cfg: &mut web::ServiceConfig, metrics_handler: PrometheusMetricsHandler, @@ -87,7 +100,8 @@ pub fn configure_internal_backstage( .service(info) .service(tokens) .service(ready) - .service(web::resource("/metrics").route(web::get().to(metrics_handler))); + .service(web::resource("/metrics").route(web::get().to(metrics_handler))) + .service(features); } #[cfg(test)]