Shared state

This commit is contained in:
Andras Schmelczer 2026-03-17 21:08:32 +00:00
parent 53fff3efaa
commit 15fa09430b
25 changed files with 174 additions and 215 deletions

View file

@ -1,12 +1,13 @@
use std::sync::Arc;
use axum::extract::State;
use axum::response::Json;
use serde::Serialize;
use tracing::info;
use crate::data::{Histogram, PropertyData};
use crate::features::{ENUM_FEATURE_GROUPS, FEATURE_GROUPS};
use crate::state::AppState;
use crate::state::SharedState;
fn is_empty(val: &str) -> bool {
val.is_empty()
@ -154,7 +155,8 @@ pub fn build_features_response(data: &PropertyData) -> FeaturesResponse {
FeaturesResponse { groups }
}
pub async fn get_features(state: Arc<AppState>) -> Json<FeaturesResponse> {
pub async fn get_features(State(shared): State<Arc<SharedState>>) -> Json<FeaturesResponse> {
let state = shared.load_state();
info!("GET /api/features");
Json(state.features_response.clone())
}