summaryrefslogtreecommitdiff
path: root/dichroism/src/handlers.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-10-31 10:44:31 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-10-31 10:44:31 -0400
commit050e40c03900827057ab5db2f6bbe971a6408fda (patch)
treecaa3a97208d077e2206f735f9ecd6618b4ac9ebf /dichroism/src/handlers.rs
parent3e1eadbbfdca1b2c0cb32ba4c8e1160a60e0ccb8 (diff)
downloadtheglassyladies-050e40c03900827057ab5db2f6bbe971a6408fda.tar.xz
theglassyladies-050e40c03900827057ab5db2f6bbe971a6408fda.zip
blocking on photo set generation since it hits the fs
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