pub struct Response {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Option<Bytes>,
pub version: Version,
}
Fields§
§status: StatusCode
The HTTP status code of the response. This is a 3-digit integer that indicates the result of the request.
headers: HeaderMap
The 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.
version: Version
The HTTP version of the response.
Implementations§
Source§impl Response
impl Response
Sourcepub fn set_status(&mut self, status: u16) -> &mut Response
pub fn set_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.
Sourcepub fn send_bytes(&mut self, data: impl Into<Vec<u8>>)
pub fn send_bytes(&mut self, data: impl Into<Vec<u8>>)
Sends Given Bytes as plain text
Sourcepub fn send_html(&mut self, data: impl Into<String>)
pub fn send_html(&mut self, data: impl Into<String>)
Takes a String(Should be valid HTML) and sends it’s as Html