pub struct Response {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Option<Bytes>,
pub version: Version,
}Fields§
§status: StatusCodeThe HTTP status code of the response. This is a 3-digit integer that indicates the result of the request.
headers: HeaderMapThe headers of the HTTP response. Headers are key-value pairs that provide additional information about the response.
body: Option<Bytes>The body of the HTTP response.
This is the content that is sent back to the client.
The body is represented as a Bytes object for efficient handling of binary data.
But The Other Method like json(),body()can be used to get the body in different formats.
version: VersionThe HTTP version of the response.
Implementations§
Source§impl Response
impl Response
Sourcepub fn status(&mut self, status: u16) -> &mut Response
pub fn status(&mut self, status: u16) -> &mut Response
Sets the StatusCode of the response and Returns a Muteable Reference to the Response so you can things like
res.status(200).send_text("eyo");The StatusCode is a 3-digit integer that indicates the result of the request.
Sourcepub fn add_header(&mut self, key: &str, value: &str) -> Option<()>
pub fn add_header(&mut self, key: &str, value: &str) -> Option<()>
Adds a header to the response. The header is a key-value pair that provides additional information about the response.