tsk-245: Modify result when getting songs but no songs are present (#247)

* tsk-245: Modify result when getting songs but no songs are present

* tsk-245: Fixed endpoint indicating success when no content is found

* tsk-245: Version bump
This commit was merged in pull request #247.
This commit is contained in:
KD
2025-11-07 11:48:07 -05:00
committed by GitHub
parent dbbbf02acf
commit bcd960d9a1
3 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -251,9 +251,14 @@ pub mod endpoint {
match repo::song::get_all_songs(&pool).await {
Ok(songs) => {
response.message = String::from(super::super::response::SUCCESSFUL);
response.data = songs;
(axum::http::StatusCode::OK, axum::Json(response))
if songs.is_empty() {
response.message = String::from("No songs available");
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
} else {
response.message = String::from(super::super::response::SUCCESSFUL);
response.data = songs;
(axum::http::StatusCode::OK, axum::Json(response))
}
}
Err(err) => {
response.message = err.to_string();