Shared state
This commit is contained in:
parent
53fff3efaa
commit
15fa09430b
25 changed files with 174 additions and 215 deletions
|
|
@ -1,13 +1,13 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use axum::extract::Query;
|
||||
use axum::extract::{Query, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::Json;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::info;
|
||||
|
||||
use crate::data::slugify;
|
||||
use crate::state::AppState;
|
||||
use crate::state::SharedState;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PlaceResult {
|
||||
|
|
@ -35,9 +35,10 @@ pub struct PlacesParams {
|
|||
}
|
||||
|
||||
pub async fn get_places(
|
||||
state: Arc<AppState>,
|
||||
State(shared): State<Arc<SharedState>>,
|
||||
Query(params): Query<PlacesParams>,
|
||||
) -> Result<Json<PlacesResponse>, (StatusCode, String)> {
|
||||
let state = shared.load_state();
|
||||
let query = if params.q.is_empty() {
|
||||
return Err((StatusCode::BAD_REQUEST, "'q' must not be empty".into()));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue