Currently the body_json function returns a std::io::Result, which gets converted into a 500 status code later. While this is probably ok for actual io errors, any errors happening during parsing of the json bytes are more likely caused by incorrect data being send by the client and so should result in a 400 Bad Request status code.
See
|
Ok(serde_json::from_slice(&body_bytes).map_err(|_| std::io::ErrorKind::InvalidData)?) |