From 573261911d552834028f11b7571b2ba3de551bfe Mon Sep 17 00:00:00 2001 From: xzeldon Date: Mon, 3 Apr 2023 04:38:25 +0300 Subject: [PATCH] return image response instead vector --- src/routes/liquid.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/routes/liquid.rs b/src/routes/liquid.rs index c493636..e403a93 100644 --- a/src/routes/liquid.rs +++ b/src/routes/liquid.rs @@ -1,10 +1,19 @@ -use axum::{extract::Multipart, Json}; +use axum::{ + body::Full, + extract::Multipart, + http::HeaderMap, + response::{IntoResponse, Response}, +}; use crate::{ processors::liquid_rescale_processor::liquid_rescale_processor, utilities::app_error::AppError, }; -pub async fn liquid_rescale_route(multipart: Multipart) -> Result>, AppError> { +pub async fn liquid_rescale_route(multipart: Multipart) -> Result { let image_data = liquid_rescale_processor(multipart).await?; - Ok(Json(image_data)) + let body = Full::from(image_data); + + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", "image/jpeg".parse().unwrap()); + Ok((headers, body).into_response()) }