Stream song #164

Merged
kdeng00 merged 11 commits from stream_song into v0.2 2025-07-27 14:20:42 -04:00
2 changed files with 20 additions and 13 deletions
Showing only changes of commit c63ec150dc - Show all commits
+10 -5
View File
@@ -1012,7 +1012,6 @@ pub mod endpoint {
} }
} }
pub async fn stream_song( pub async fn stream_song(
axum::Extension(pool): axum::Extension<sqlx::PgPool>, axum::Extension(pool): axum::Extension<sqlx::PgPool>,
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>, axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
@@ -1033,7 +1032,12 @@ pub mod endpoint {
let file_size = match file.metadata().await { let file_size = match file.metadata().await {
Ok(meta) => meta.len(), Ok(meta) => meta.len(),
Err(_) => return Err((axum::http::StatusCode::INTERNAL_SERVER_ERROR, "Could not read file")), Err(_) => {
return Err((
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
"Could not read file",
));
}
}; };
let mime = mime_guess::from_path(path).first_or_octet_stream(); let mime = mime_guess::from_path(path).first_or_octet_stream();
@@ -1048,9 +1052,10 @@ pub mod endpoint {
Ok(rep) Ok(rep)
} }
Err(_err) => { Err(_err) => Err((
Err((axum::http::StatusCode::INTERNAL_SERVER_ERROR, "Could not find file")) axum::http::StatusCode::INTERNAL_SERVER_ERROR,
} "Could not find file",
)),
} }
} }
} }
+5 -3
View File
@@ -123,7 +123,10 @@ pub mod init {
crate::callers::endpoints::GETCOVERART, crate::callers::endpoints::GETCOVERART,
get(crate::callers::coverart::endpoint::get_coverart), get(crate::callers::coverart::endpoint::get_coverart),
) )
.route(crate::callers::endpoints::STREAMSONG, get(crate::callers::song::endpoint::stream_song)) .route(
crate::callers::endpoints::STREAMSONG,
get(crate::callers::song::endpoint::stream_song),
)
} }
pub async fn app() -> axum::Router { pub async fn app() -> axum::Router {
@@ -1980,8 +1983,7 @@ mod tests {
let mut data = e.into_data_stream(); let mut data = e.into_data_stream();
while let Some(chunk) = data.next().await { while let Some(chunk) = data.next().await {
match chunk { match chunk {
Ok(_data) => { Ok(_data) => {}
}
Err(err) => { Err(err) => {
assert!(false, "Error: {err:?}"); assert!(false, "Error: {err:?}");
} }