Add PUT /family/{id}/member/{id_member}
This commit is contained in:
parent
e59ed6ed71
commit
eaf09135f4
@ -252,3 +252,17 @@ pub async fn get_all(f: FamilyInPath) -> HttpResult {
|
||||
pub async fn get_single(m: FamilyAndMemberInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(m.to_member()))
|
||||
}
|
||||
|
||||
/// Update a member information
|
||||
pub async fn update(m: FamilyAndMemberInPath, req: web::Json<MemberRequest>) -> HttpResult {
|
||||
let mut member = m.to_member();
|
||||
|
||||
if let Err(e) = req.0.to_member(&mut member).await {
|
||||
log::error!("Failed to parse member information {e}!");
|
||||
return Ok(HttpResponse::BadRequest().body(e.to_string()));
|
||||
}
|
||||
|
||||
members_service::update(&mut member).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
@ -135,6 +135,10 @@ async fn main() -> std::io::Result<()> {
|
||||
"/family/{id}/member/{member_id}",
|
||||
web::get().to(members_controller::get_single),
|
||||
)
|
||||
.route(
|
||||
"/family/{id}/member/{member_id}",
|
||||
web::put().to(members_controller::update),
|
||||
)
|
||||
})
|
||||
.bind(AppConfig::get().listen_address.as_str())?
|
||||
.run()
|
||||
|
Loading…
Reference in New Issue
Block a user