Skip to content

Commit

Permalink
feat: internal backstage features endpoint (#422)
Browse files Browse the repository at this point in the history
Adds an endpoint /internal-backstage/features displaying which features
we store per cache key
  • Loading branch information
Christopher Kolstad authored Feb 28, 2024
1 parent 8996a80 commit 3ca7069
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/src/internal_backstage.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -79,6 +81,17 @@ pub async fn tokens(
token_validation_status,
}))
}

#[get("/features")]
pub async fn features(
features_cache: web::Data<DashMap<String, ClientFeatures>>,
) -> EdgeJsonResult<HashMap<String, ClientFeatures>> {
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,
Expand All @@ -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)]
Expand Down

0 comments on commit 3ca7069

Please sign in to comment.