diff --git a/src/callers/song.rs b/src/callers/song.rs index b17e40b..fedca18 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -1012,7 +1012,6 @@ pub mod endpoint { } } - pub async fn stream_song( axum::Extension(pool): axum::Extension, axum::extract::Path(id): axum::extract::Path, @@ -1033,24 +1032,30 @@ pub mod endpoint { let file_size = match file.metadata().await { 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 stream = tokio_util::io::ReaderStream::new(file); let rep = axum::response::Response::builder() - .header("content-type", mime.to_string()) - .header("accept-ranges", "bytes") - .header("content-length", file_size.to_string()) - .body(axum::body::Body::from_stream(stream)) - .unwrap(); + .header("content-type", mime.to_string()) + .header("accept-ranges", "bytes") + .header("content-length", file_size.to_string()) + .body(axum::body::Body::from_stream(stream)) + .unwrap(); Ok(rep) } - Err(_err) => { - Err((axum::http::StatusCode::INTERNAL_SERVER_ERROR, "Could not find file")) - } + Err(_err) => Err(( + axum::http::StatusCode::INTERNAL_SERVER_ERROR, + "Could not find file", + )), } } } diff --git a/src/main.rs b/src/main.rs index 08fb379..f3879c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,7 +123,10 @@ pub mod init { crate::callers::endpoints::GETCOVERART, 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 { @@ -1980,8 +1983,7 @@ mod tests { let mut data = e.into_data_stream(); while let Some(chunk) = data.next().await { match chunk { - Ok(_data) => { - } + Ok(_data) => {} Err(err) => { assert!(false, "Error: {err:?}"); }