Converted the Api to a Restful api.

This commit is contained in:
2026-01-22 22:51:03 +01:00
parent 79ba1e1b44
commit 9d3c5afb07
50 changed files with 2194 additions and 1939 deletions

View File

@@ -0,0 +1,28 @@
use actix_web::{delete, web, HttpResponse, Responder};
use gamenight_database::{DbPool, GetConnection};
use gamenight_database::gamenight_participants::GamenightParticipant;
use uuid::Uuid;
use crate::request::authorization::AuthUser;
use crate::request::error::ApiError;
#[delete("/gamenight/{gamenightId}/participant/{userId}")]
pub async fn delete_gamenight_participant(
pool: web::Data<DbPool>,
_user: AuthUser,
gamenight_id: web::Path<Uuid>,
user_id: web::Path<Uuid>
) -> Result<impl Responder, ApiError> {
web::block(move || -> Result<usize, ApiError> {
let mut conn = pool.get_conn();
let participant = GamenightParticipant {
gamenight_id: gamenight_id.into_inner(),
user_id: user_id.into_inner(),
};
let x = gamenight_database::gamenight_participants::delete_gamenight_participant(&mut conn, participant)?;
Ok(x)
})
.await??;
Ok(HttpResponse::Ok())
}