From 1b1f0f7e684719826e2ee727dcfbebedd01b4c51 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 26 Sep 2023 20:01:37 +0200 Subject: [PATCH] test if empty --- src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index d0e1582..f10d97b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,6 +169,13 @@ async fn get_progress( ) .unwrap(); + if values.is_empty() { + return ( + StatusCode::FORBIDDEN, + Json(json!(r#""message": "Field 'document' not provided."#)), + ); + } + let res = GetProgress { percentage: values[0].parse().unwrap(), progress: values[1].clone(), @@ -181,6 +188,6 @@ async fn get_progress( (StatusCode::OK, Json(json!(res))) } -async fn healthcheck() -> (StatusCode, String) { - (StatusCode::OK, "{ \"state\" : \"OK\" }".to_owned()) +async fn healthcheck() -> (StatusCode, Json) { + (StatusCode::OK, Json(json!("{ \"state\" : \"OK\" }"))) }