rebuild file structur + simple sqlite db endpoint

This commit is contained in:
2025-09-04 22:32:53 +02:00
parent 3db51cc805
commit 3450c216c0
20 changed files with 748 additions and 49 deletions

39
src/rooms/extractor.rs Normal file
View File

@@ -0,0 +1,39 @@
use axum::{
extract::{Request, FromRequest, Path},
body::{Body},
http::StatusCode,
Json, Router,
};
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct UpdateRoomValues {
pub status: String,
pub token: String,
pub hotel_id: i32,
}
pub struct UpdateRoomPayload(pub UpdateRoomValues);
//#[async_trait]
impl<S> FromRequest<S> for UpdateRoomPayload
where S: Send + Sync,
{
type Rejection = (StatusCode, String);
async fn from_request(req: Request, state: &S) -> Result<Self, Self::Rejection> {
let Json(payload) = Json::<UpdateRoomValues>::from_request(req, state)
.await
.map_err(|err| (StatusCode::BAD_REQUEST, format!("Invalid body: {}", err)))?;
Ok(UpdateRoomPayload(payload))
}
}
#[derive(Debug)]
pub struct RoomIdValue {
pub room_id: i32
}
pub type RoomIdPath = Path<i32>;