Suggestion from @SupernaviX to improve REST handlers - if RESTResponse::with_json() could take a T: Serialize, and returned a Result<()>, it could do the serialisation and error handling itself:
Some(stake) => match serde_json::to_string(&stake) {
Ok(body) => Ok(RESTResponse::with_json(200, &body)),
Err(error) => Err(anyhow!("{:?}", error)),
},
becomes
Some(stake) => RESTResponse::with_json(200, &stake)