Rename send_data to send_json_data
This commit is contained in:
parent
dc2f0334b6
commit
8b848a6fc0
1 changed files with 5 additions and 5 deletions
10
src/mouth.rs
10
src/mouth.rs
|
@ -34,7 +34,7 @@ impl<'a> Mouth<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send response data in JSON to a client.
|
/// 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 contents = data.to_string();
|
||||||
let length = contents.len();
|
let length = contents.len();
|
||||||
let response = format!("{status_code}\r\nContent-Type: application/json\r\nContent-Length: {length}\r\n\r\n{contents}");
|
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
|
where
|
||||||
T: Serialize,
|
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.
|
/// Send BadRequest response to a client.
|
||||||
|
@ -62,7 +62,7 @@ impl<'a> Mouth<'a> {
|
||||||
data
|
data
|
||||||
};
|
};
|
||||||
|
|
||||||
self.send_data(Status::BadRequest, data);
|
self.send_json_data(Status::BadRequest, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send InternalError response to a client.
|
/// Send InternalError response to a client.
|
||||||
|
@ -70,7 +70,7 @@ impl<'a> Mouth<'a> {
|
||||||
where
|
where
|
||||||
T: Serialize,
|
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.
|
/// Send NotFound response to a client.
|
||||||
|
@ -78,6 +78,6 @@ impl<'a> Mouth<'a> {
|
||||||
where
|
where
|
||||||
T: Serialize,
|
T: Serialize,
|
||||||
{
|
{
|
||||||
self.send_data(Status::NotFound, serde_json::json!(data));
|
self.send_json_data(Status::NotFound, serde_json::json!(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue