Skip to content

Commit

Permalink
chore: more messages on HTTP server
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Oct 22, 2024
1 parent 2217050 commit 3f00efb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ fn handle_request(
Ok(mut file) => {
let mut buffer = Vec::new();
std::io::copy(&mut file, &mut buffer).map_err(|e| e.to_string())?;
info!(
"\"{} {} HTTP/{}\" 200 -",
request.method(),
request_path,
request.http_version()
);
Ok(Response::from_data(buffer))
}
Err(err) => {
Expand All @@ -52,7 +58,12 @@ fn handle_request(
}
}
} else {
error!("File not found: {}", file_path.display());
error!(
"\"{} {} HTTP/{}\" 404 -",
request.method(),
request_path,
request.http_version()
);
Ok(Response::from_string("404 Not Found").with_status_code(404))
}
}

0 comments on commit 3f00efb

Please sign in to comment.