Rename send_data to send_json_data

This commit is contained in:
flyingscorpio@clevo 2023-01-08 13:39:54 +01:00
parent dc2f0334b6
commit 8b848a6fc0

View file

@ -34,7 +34,7 @@ impl<'a> Mouth<'a> {
}
/// Send response data in JSON to a client.
fn send_data(&mut self, status_code: Status, data: Value) {
fn send_json_data(&mut self, status_code: Status, data: Value) {
let contents = data.to_string();
let length = contents.len();
let response = format!("{status_code}\r\nContent-Type: application/json\r\nContent-Length: {length}\r\n\r\n{contents}");
@ -47,7 +47,7 @@ impl<'a> Mouth<'a> {
where
T: Serialize,
{
self.send_data(Status::OK, serde_json::json!(data));
self.send_json_data(Status::OK, serde_json::json!(data));
}
/// Send BadRequest response to a client.
@ -62,7 +62,7 @@ impl<'a> Mouth<'a> {
data
};
self.send_data(Status::BadRequest, data);
self.send_json_data(Status::BadRequest, data);
}
/// Send InternalError response to a client.
@ -70,7 +70,7 @@ impl<'a> Mouth<'a> {
where
T: Serialize,
{
self.send_data(Status::InternalError, serde_json::json!(data));
self.send_json_data(Status::InternalError, serde_json::json!(data));
}
/// Send NotFound response to a client.
@ -78,6 +78,6 @@ impl<'a> Mouth<'a> {
where
T: Serialize,
{
self.send_data(Status::NotFound, serde_json::json!(data));
self.send_json_data(Status::NotFound, serde_json::json!(data));
}
}