all names endpoint

This commit is contained in:
2026-04-09 14:30:56 +02:00
parent 3eb1da8319
commit cec765bcf3
2 changed files with 6 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ pub fn api_router() -> Router {
.route("/api/persons/{id}", get(persons::get_by_id))
.route("/api/persons/{id}/names", get(persons::pid_names))
.route("/api/persons/{id}/addname", post(persons::add_name))
.route("/api/names", get(persons::n_all))
.route("/api/names/{id}", get(persons::n_by_id))
.route("/api/names/{id}/setprimary", post(persons::n_setprimary))
// quotes

View File

@@ -93,6 +93,11 @@ pub async fn add_name(
Ok((StatusCode::CREATED, Json(n)).into_response())
}
pub async fn n_all(headers: HeaderMap) -> Result<Response, CompositeError> {
User::authenticate(&headers)?.required()?;
let conn = database::conn()?;
Ok(Json(Name::get_all(&conn)?).into_response())
}
pub async fn n_by_id(Path(id): Path<Uuid>, headers: HeaderMap) -> Result<Response, CompositeError> {
User::authenticate(&headers)?.required()?;
let conn = database::conn()?;