Get songs endpoint #162

Merged
kdeng00 merged 27 commits from get_songs into v0.2 2025-07-25 18:20:28 -04:00
Showing only changes of commit 1281913c36 - Show all commits
+19 -2
View File
@@ -170,7 +170,7 @@ pub mod response {
#[derive(Debug, Default, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<i32>,
pub data: Vec<icarus_models::song::Song>,
}
}
}
@@ -993,6 +993,23 @@ pub mod endpoint {
) {
let mut response = super::response::get_songs::Response::default();
(axum::http::StatusCode::OK, axum::Json(response))
match params.id {
Some(id) => {
match super::song_db::get_song(&pool, &id).await {
Ok(song) => {
response.data.push(song);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
response.message = err.to_string();
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
}
None => {
response.message = String::from("Invalid parameters");
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
}
}