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,6 +1,6 @@
use std::sync::Arc;
use axum::extract::Query;
use axum::extract::{Query, State};
use axum::http::StatusCode;
use axum::response::{IntoResponse, Json};
use axum::Extension;
@ -11,7 +11,7 @@ use crate::auth::OptionalUser;
use crate::consts::{DEFAULT_PROPERTIES_LIMIT, MAX_PROPERTIES_LIMIT, POSTCODE_SEARCH_OFFSET};
use crate::licensing::check_license_point;
use crate::parsing::{parse_filters, row_passes_filters};
use crate::state::AppState;
use crate::state::SharedState;
use crate::utils::normalize_postcode;
use super::properties::{HexagonPropertiesResponse, Property};
@ -25,10 +25,11 @@ pub struct PostcodePropertiesParams {
}
pub async fn get_postcode_properties(
state: Arc<AppState>,
State(shared): State<Arc<SharedState>>,
Extension(user): Extension<OptionalUser>,
Query(params): Query<PostcodePropertiesParams>,
) -> Result<Json<HexagonPropertiesResponse>, axum::response::Response> {
let state = shared.load_state();
let normalized = normalize_postcode(&params.postcode);
let pc_idx = match state.postcode_data.postcode_to_idx.get(&normalized) {