pub struct Http;Implementations§
Source§impl Http
impl Http
Sourcepub fn from(stream: TcpStream) -> Result<(Request, Response)>
pub fn from(stream: TcpStream) -> Result<(Request, Response)>
Examples found in repository?
More examples
examples/hello_world.rs (line 11)
7fn main() -> io::Result<()> {
8 let listener = TcpListener::bind("127.0.0.1:8080")?;
9
10 for stream in listener.incoming().filter_map(Result::ok) {
11 let (request, response) = Http::from(stream)?;
12
13 println!("New Request: ");
14 println!("- method: {:?}", request.method);
15 println!("- uri: {:?}", request.uri);
16 println!("- params: {:?}", request.params);
17 println!("- http_version: {:?}", request.http_version);
18 println!("- headers: {:?}", request.headers);
19
20 response.status_code(StatusCode::Ok)
21 .set_header("Content-Type", "text/html").flush()?
22 .add_to_body("<h1>Hello from Rust!</h1>").flush()?;
23 }
24
25 Ok(())
26}Auto Trait Implementations§
impl Freeze for Http
impl RefUnwindSafe for Http
impl Send for Http
impl Sync for Http
impl Unpin for Http
impl UnwindSafe for Http
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