summaryrefslogtreecommitdiff
path: root/dichroism/src/main.rs
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-10-03 22:07:39 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-10-03 22:07:39 -0400
commit8da473460c3f82737ff34d02006ceac4c289243c (patch)
treea16128726bb163fa2877f5990e032fde12ecea4c /dichroism/src/main.rs
parent58c6bd29b2efd14d7ae386124adf0750e6179370 (diff)
downloadtheglassyladies-8da473460c3f82737ff34d02006ceac4c289243c.tar.xz
theglassyladies-8da473460c3f82737ff34d02006ceac4c289243c.zip
broke out functions, wrote more tests, added test data
Diffstat (limited to 'dichroism/src/main.rs')
-rw-r--r--dichroism/src/main.rs8
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()