From 8da473460c3f82737ff34d02006ceac4c289243c Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Sat, 3 Oct 2020 22:07:39 -0400 Subject: broke out functions, wrote more tests, added test data --- dichroism/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dichroism/src/main.rs') 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() -- cgit v1.2.3