diff --git a/src/router/upload.rs b/src/router/upload.rs index 410b20c..3620081 100644 --- a/src/router/upload.rs +++ b/src/router/upload.rs @@ -4,7 +4,7 @@ use askama::Template; use async_zip::{base::write::ZipFileWriter, Compression, ZipEntryBuilder}; use axum::{ extract::{DefaultBodyLimit, Multipart, State}, - http::Response, + response::{IntoResponse, Response}, routing::post, Router, }; @@ -30,7 +30,7 @@ pub fn get_upload_router() -> Router { async fn upload_to_zip( State(state): State, mut body: Multipart, -) -> Result, (StatusCode, String)> { +) -> Result { tracing::debug!("{:?}", *state.records.lock().await); let cache_name = util::get_random_name(10); @@ -85,12 +85,14 @@ async fn upload_to_zip( writer.close().await.unwrap(); let id = cache_name; - let response = Response::builder() - .status(200) - .header("Content-Type", "text/html") - .header("HX-Push-Url", format!("/link/{}", &id)) - .body(DownloadLinkFragment { id, record }.render().unwrap()) - .unwrap(); + let impl_response = ( + StatusCode::OK, + [ + ("Content-Type", "text/html"), + ("HX-Push-Url", &format!("/link/{}", &id)), + ], + DownloadLinkFragment { id, record }, + ); - Ok(response) + Ok(impl_response.into_response()) }