Rewrite to chatty but functional API.
This commit is contained in:
17
backend-actix/src/request/participant_handlers.rs
Normal file
17
backend-actix/src/request/participant_handlers.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use actix_web::{get, http::header::ContentType, web, HttpResponse, Responder};
|
||||
use gamenight_database::{DbPool, GetConnection};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{models::{gamenight_id::GamenightId, participants::Participants}, request::{authorization::AuthUser, error::ApiError}};
|
||||
|
||||
#[get("/participants")]
|
||||
pub async fn get_get_participants(pool: web::Data<DbPool>, _user: AuthUser, gamenight_info: web::Json<GamenightId>) -> Result<impl Responder, ApiError> {
|
||||
let mut conn = pool.get_conn();
|
||||
|
||||
let users = gamenight_database::get_participants(&mut conn, &Uuid::parse_str(&gamenight_info.into_inner().gamenight_id)?)?
|
||||
.iter().map(|x| x.to_string()).collect();
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(serde_json::to_string(&Participants{participants: users})?))
|
||||
}
|
||||
Reference in New Issue
Block a user