Connection handling not a method of context anymore
This commit is contained in:
parent
337ca0149e
commit
34b8307426
@ -52,7 +52,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.handle_connection(&path, stream, &pool);
|
handle_connection(&mut context, &path, stream, &pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +133,7 @@ struct Context {
|
|||||||
infos: HashMap<Box<str>, Arc<Mutex<SiteInfo>>>,
|
infos: HashMap<Box<str>, Arc<Mutex<SiteInfo>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Context {
|
fn handle_connection(context: &mut Context, path: &Path, mut stream: TcpStream, pool: &ThreadPool) {
|
||||||
fn handle_connection(&mut self, path: &Path, mut stream: TcpStream, pool: &ThreadPool) {
|
|
||||||
let Some(request) = Request::from(&stream) else {
|
let Some(request) = Request::from(&stream) else {
|
||||||
eprintln!("Invalid request!");
|
eprintln!("Invalid request!");
|
||||||
return;
|
return;
|
||||||
@ -211,7 +210,7 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use Entry::*;
|
use Entry::*;
|
||||||
let info = match self.infos.entry(relative_path.clone().into_boxed_str()) {
|
let info = match context.infos.entry(relative_path.clone().into_boxed_str()) {
|
||||||
Occupied(o) => o.get().clone(),
|
Occupied(o) => o.get().clone(),
|
||||||
Vacant(v) => v
|
Vacant(v) => v
|
||||||
.insert(Arc::new(Mutex::new(
|
.insert(Arc::new(Mutex::new(
|
||||||
@ -238,7 +237,6 @@ impl Context {
|
|||||||
start_level,
|
start_level,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reply_image(mut stream: TcpStream, relative_path: &str, mut path: PathBuf) {
|
fn reply_image(mut stream: TcpStream, relative_path: &str, mut path: PathBuf) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user