Download coverart endpoint #166
+13
-11
@@ -647,10 +647,10 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn download_coverart(axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>) ->
|
||||
(axum::http::StatusCode, axum::response::Response) {
|
||||
|
||||
pub async fn download_coverart(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||
) -> (axum::http::StatusCode, axum::response::Response) {
|
||||
match super::cov_db::get_coverart(&pool, &id).await {
|
||||
Ok(coverart) => match coverart.to_data() {
|
||||
Ok(data) => {
|
||||
@@ -671,13 +671,15 @@ pub mod endpoint {
|
||||
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(_err) => {
|
||||
(axum::http::StatusCode::NOT_FOUND, axum::response::Response::default())
|
||||
}
|
||||
}
|
||||
Err(_err) => {
|
||||
(axum::http::StatusCode::NOT_FOUND, axum::response::Response::default())
|
||||
}
|
||||
Err(_err) => (
|
||||
axum::http::StatusCode::NOT_FOUND,
|
||||
axum::response::Response::default(),
|
||||
),
|
||||
},
|
||||
Err(_err) => (
|
||||
axum::http::StatusCode::NOT_FOUND,
|
||||
axum::response::Response::default(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -123,7 +123,10 @@ pub mod init {
|
||||
crate::callers::endpoints::GETCOVERART,
|
||||
get(crate::callers::coverart::endpoint::get_coverart),
|
||||
)
|
||||
.route(crate::callers::endpoints::DOWNLOADCOVERART, get(crate::callers::coverart::endpoint::download_coverart))
|
||||
.route(
|
||||
crate::callers::endpoints::DOWNLOADCOVERART,
|
||||
get(crate::callers::coverart::endpoint::download_coverart),
|
||||
)
|
||||
.route(
|
||||
crate::callers::endpoints::STREAMSONG,
|
||||
get(crate::callers::song::endpoint::stream_song),
|
||||
@@ -2085,7 +2088,8 @@ mod tests {
|
||||
let id = test_data::coverart_id().await.unwrap();
|
||||
|
||||
let uri =
|
||||
super::format_url_with_value(crate::callers::endpoints::DOWNLOADCOVERART, &id).await;
|
||||
super::format_url_with_value(crate::callers::endpoints::DOWNLOADCOVERART, &id)
|
||||
.await;
|
||||
|
||||
match app
|
||||
.clone()
|
||||
|
||||
Reference in New Issue
Block a user