forked from Roflin/gamenight
Converted the Api to a Restful api.
This commit is contained in:
28
backend-actix/src/request/gamenight_participant.rs
Normal file
28
backend-actix/src/request/gamenight_participant.rs
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user