Add GET /family/{id}/members

This commit is contained in:
Pierre HUBERT 2023-08-05 10:38:10 +02:00
parent 5f0842b7dc
commit e59ed6ed71
2 changed files with 10 additions and 0 deletions

View File

@ -242,6 +242,12 @@ pub async fn create(f: FamilyInPath, req: web::Json<MemberRequest>) -> 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()))

View File

@ -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),