summaryrefslogtreecommitdiff
path: root/dichroism/src/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dichroism/src/handlers.rs')
-rw-r--r--dichroism/src/handlers.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/dichroism/src/handlers.rs b/dichroism/src/handlers.rs
index 7c1d302..0480abf 100644
--- a/dichroism/src/handlers.rs
+++ b/dichroism/src/handlers.rs
@@ -43,10 +43,12 @@ async fn patch_product(
if let Some(data_uri) = patch.photo_data {
// create new photo_set
- let photo_set = image_service::generate_photo_set(&data_uri).map_err(|e| {
- eprintln!("{}", e.to_string());
- HttpResponse::InternalServerError().body(e.to_string())
- })?;
+ let photo_set = web::block(move || image_service::generate_photo_set(&data_uri))
+ .await
+ .map_err(|e| {
+ eprintln!("{}", e.to_string());
+ HttpResponse::InternalServerError().body(e.to_string())
+ })?;
let conn = pool.get().map_err(to_internal_error)?;
let photo_set = web::block(move || repo::store_photo_set(&conn, photo_set))
.await
@@ -79,10 +81,13 @@ async fn post_product(
let post = post.into_inner();
// create new photo_set
- let photo_set = image_service::generate_photo_set(&post.photo_data).map_err(|e| {
- eprintln!("{}", e.to_string());
- HttpResponse::InternalServerError().body(e.to_string())
- })?;
+ let data_uri = post.photo_data;
+ let photo_set = web::block(move || image_service::generate_photo_set(&data_uri))
+ .await
+ .map_err(|e| {
+ eprintln!("{}", e.to_string());
+ HttpResponse::InternalServerError().body(e.to_string())
+ })?;
let conn = pool.get().map_err(to_internal_error)?;
let photo_set = web::block(move || repo::store_photo_set(&conn, photo_set))
.await