diff --git a/src/webserver.rs b/src/webserver.rs index f7b37c7..dd156b1 100644 --- a/src/webserver.rs +++ b/src/webserver.rs @@ -114,10 +114,19 @@ async fn get_mapping(store: &State>>) -> Json { } #[post("/api/mapping", format = "json", data = "")] -async fn add_mapping(store: &State>>, new_mapping: Json) { +async fn add_mapping(store: &State>>, new_mapping: Json) -> Status { + if new_mapping.id.is_empty() + || new_mapping.name.first.is_empty() + || new_mapping.name.last.is_empty() + { + return Status::BadRequest; + } + store .lock() .await .mapping .add_mapping(TallyID(new_mapping.id.clone()), new_mapping.name.clone()); + + Status::Created }