Struct ezhttp::HttpResponse
source · pub struct HttpResponse {
pub headers: Headers,
pub status_code: String,
pub data: Vec<u8>,
}Fields§
§headers: Headers§status_code: String§data: Vec<u8>Implementations§
source§impl HttpResponse
impl HttpResponse
pub fn new(headers: Headers, status_code: String, data: Vec<u8>) -> Self
pub fn from_str(headers: Headers, status_code: String, data: &str) -> Self
sourcepub fn from_string(headers: Headers, status_code: String, data: String) -> Self
pub fn from_string(headers: Headers, status_code: String, data: String) -> Self
Examples found in repository?
examples/simple_site.rs (lines 16-20)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
fn ok_response(&mut self, content: String) -> HttpResponse {
HttpResponse::from_string(
Headers::from(vec![("Content-Type", "text/html")]),
"200 OK".to_string(),
content,
)
}
fn not_found_response(&mut self, content: String) -> HttpResponse {
HttpResponse::from_string(
Headers::from(vec![("Content-Type", "text/html")]),
"404 Not Found".to_string(),
content,
)
}pub fn get_text(self) -> String
pub fn get_json(self) -> Value
pub fn read(data: &mut TcpStream) -> Result<HttpResponse, HttpError>
pub fn write(self, data: &mut TcpStream) -> Result<(), &str>
Trait Implementations§
source§impl Clone for HttpResponse
impl Clone for HttpResponse
source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for HttpResponse
impl Debug for HttpResponse
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more