summaryrefslogtreecommitdiff
path: root/src/routes/album.rs
diff options
context:
space:
mode:
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