From f98a33bbe9753db03a71fa754a2c37276cc2403b Mon Sep 17 00:00:00 2001 From: Dom Date: Mon, 11 Jan 2021 13:25:22 +0000 Subject: [PATCH] fix: invalid API request body causes panic Removes a stray unwrap() that was causing a request with invalid JSON / empty body to panic the handler thread. Fixes #632 --- src/server/http_routes.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/server/http_routes.rs b/src/server/http_routes.rs index 504b426a0c..59b3282dcb 100644 --- a/src/server/http_routes.rs +++ b/src/server/http_routes.rs @@ -466,9 +466,8 @@ async fn create_database( .clone(); let body = parse_body(req).await?; - let rules: DatabaseRules = serde_json::from_slice(body.as_ref()) - .context(InvalidRequestBody) - .unwrap(); + let rules: DatabaseRules = serde_json::from_slice(body.as_ref()).context(InvalidRequestBody)?; + server .create_database(db_name, rules) .await