diff options
Diffstat (limited to 'dichroism/src/main.rs')
-rw-r--r-- | dichroism/src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dichroism/src/main.rs b/dichroism/src/main.rs index fef8096..f832121 100644 --- a/dichroism/src/main.rs +++ b/dichroism/src/main.rs @@ -4,6 +4,7 @@ extern crate lazy_static; use actix_web::{get, post, App, HttpResponse, HttpServer, Responder}; use listenfd::ListenFd; +mod error; mod image_api; mod result; @@ -14,7 +15,12 @@ async fn hello() -> impl Responder { #[post("/images")] async fn create_image(req_body: String) -> impl Responder { - if let Err(e) = image_api::data_uri_to_files(&req_body) { + let data = match image_api::extract_data(&req_body) { + Err(e) => return HttpResponse::BadRequest().body(format!("fail: {}", e.to_string())), + Ok(d) => d, + }; + + if let Err(e) = image_api::generate_images(data) { return HttpResponse::BadRequest().body(format!( "Unable to extract image from data URI: {}", e.to_string() |