summaryrefslogtreecommitdiff
path: root/src/routes/album.rs
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-20 22:15:14 +0100
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2025-01-20 22:15:14 +0100
commit58515ddfecd3701112616c33ad4879dae4b38ffd (patch)
tree6a3046b9005aa5247f5e077849409acdc62f17ce /src/routes/album.rs
parentdaa7aea33439a91c4dd14592d1909d78ebe472e2 (diff)
save before disaster
Diffstat (limited to 'src/routes/album.rs')
-rw-r--r--src/routes/album.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/routes/album.rs b/src/routes/album.rs
index 6f793bd..dbf04f0 100644
--- a/src/routes/album.rs
+++ b/src/routes/album.rs
@@ -16,11 +16,18 @@ pub async fn album(
get_args: web::Query<AlbumQueryOptions>,
) -> HttpResponse {
let default: String = String::from("");
+
+ if get_args.id.is_some() {
+ let id: &str = get_args.id.as_ref().unwrap_or(&default);
+ let search_attempt: sqlx::Result<Option<Album>> =
+ app_state.database.select_album_by_id(id).await;
+
+ return match search_attempt {
+ Ok(song_list) => HttpResponse::Ok().json(song_list),
+ Err(e) => HttpResponse::Ok().body(format!("{}", e)),
+ };
+ }
let search_attempt: sqlx::Result<Vec<Album>, sqlx::Error> = match true {
- _ if get_args.id.is_some() => {
- let id: &str = &get_args.id.as_ref().unwrap_or(&default);
- app_state.database.select_album_by_id(id).await
- }
_ if get_args.name.is_some() => {
let name: &str = &get_args.name.as_ref().unwrap_or(&default);
app_state.database.select_albums_by_name(name).await