Code formatting

This commit is contained in:
kdeng00
2025-07-27 14:00:15 -04:00
parent 805ab2bfcd
commit c63ec150dc
2 changed files with 20 additions and 13 deletions
+15 -10
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,24 +1032,30 @@ 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();
let stream = tokio_util::io::ReaderStream::new(file); let stream = tokio_util::io::ReaderStream::new(file);
let rep = axum::response::Response::builder() let rep = axum::response::Response::builder()
.header("content-type", mime.to_string()) .header("content-type", mime.to_string())
.header("accept-ranges", "bytes") .header("accept-ranges", "bytes")
.header("content-length", file_size.to_string()) .header("content-length", file_size.to_string())
.body(axum::body::Body::from_stream(stream)) .body(axum::body::Body::from_stream(stream))
.unwrap(); .unwrap();
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:?}");
} }