From e59ed6ed7126db20b1330e83065f4beb53fcc3df Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sat, 5 Aug 2023 10:38:10 +0200 Subject: [PATCH] Add GET /family/{id}/members --- geneit_backend/src/controllers/members_controller.rs | 6 ++++++ geneit_backend/src/main.rs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/geneit_backend/src/controllers/members_controller.rs b/geneit_backend/src/controllers/members_controller.rs index ad38211..103bf09 100644 --- a/geneit_backend/src/controllers/members_controller.rs +++ b/geneit_backend/src/controllers/members_controller.rs @@ -242,6 +242,12 @@ pub async fn create(f: FamilyInPath, req: web::Json) -> HttpResul Ok(HttpResponse::Ok().json(member)) } +/// Get the entire list of members of the family +pub async fn get_all(f: FamilyInPath) -> HttpResult { + let members = members_service::get_all_of_family(f.family_id()).await?; + Ok(HttpResponse::Ok().json(members)) +} + /// Get the information of a single family member pub async fn get_single(m: FamilyAndMemberInPath) -> HttpResult { Ok(HttpResponse::Ok().json(m.to_member())) diff --git a/geneit_backend/src/main.rs b/geneit_backend/src/main.rs index 2449cae..81b211f 100644 --- a/geneit_backend/src/main.rs +++ b/geneit_backend/src/main.rs @@ -127,6 +127,10 @@ async fn main() -> std::io::Result<()> { "/family/{id}/member/create", web::post().to(members_controller::create), ) + .route( + "/family/{id}/members", + web::get().to(members_controller::get_all), + ) .route( "/family/{id}/member/{member_id}", web::get().to(members_controller::get_single),