feat: response threaded
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::io::prelude::*;
|
||||
use std::net::{SocketAddr, TcpListener, TcpStream};
|
||||
use std::{fs, thread};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -110,12 +110,15 @@ impl HttpApp<'_> {
|
||||
|
||||
for stream in listener.incoming() {
|
||||
let mut _stream = stream.unwrap();
|
||||
|
||||
println!("Connection established!");
|
||||
let response = self.process_petition(&mut _stream);
|
||||
|
||||
// TODO: manage error case
|
||||
let _amount = _stream.write(response.data.as_bytes()).unwrap();
|
||||
_stream.flush().unwrap();
|
||||
thread::spawn(move || {
|
||||
// TODO: manage error case
|
||||
_stream.write(response.data.as_bytes()).unwrap();
|
||||
_stream.flush().unwrap();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user