diff options
| -rw-r--r-- | Cargo.lock | 9 | ||||
| -rw-r--r-- | Cargo.toml | 13 | ||||
| -rw-r--r-- | blog/Cargo.toml | 8 | ||||
| -rw-r--r-- | blog/src/main.rs | 14 | ||||
| -rw-r--r-- | spider/Cargo.toml | 9 | ||||
| -rw-r--r-- | spider/src/lib.rs (renamed from src/main.rs) | 12 |
6 files changed, 45 insertions, 20 deletions
@@ -1,5 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "rust-web" +name = "blog" +version = "0.1.0" +dependencies = [ + "spider", +] + +[[package]] +name = "spider" version = "0.1.0" @@ -1,9 +1,6 @@ -[package] -name = "rust-web" -version = "0.1.0" -authors = ["Andrew <saintruler@gmail.com>"] -edition = "2018" +[workspace] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] +members = [ + "spider", + "blog" +] diff --git a/blog/Cargo.toml b/blog/Cargo.toml new file mode 100644 index 0000000..1b8587f --- /dev/null +++ b/blog/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "blog" +version = "0.1.0" +authors = ["Andrew <saintruler@gmail.com>"] +edition = "2018" + +[dependencies] +spider = { path = "../spider" } diff --git a/blog/src/main.rs b/blog/src/main.rs new file mode 100644 index 0000000..0dba17a --- /dev/null +++ b/blog/src/main.rs @@ -0,0 +1,14 @@ +use std::net::TcpListener; + +use spider::handle_client; + +fn main() -> std::io::Result<()> { + let listener = TcpListener::bind("localhost:3000")?; + + // accept connections and process them serially + for stream in listener.incoming() { + handle_client(stream?); + } + + Ok(()) +} diff --git a/spider/Cargo.toml b/spider/Cargo.toml new file mode 100644 index 0000000..84e5702 --- /dev/null +++ b/spider/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "spider" +version = "0.1.0" +authors = ["Andrew <saintruler@gmail.com>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/spider/src/lib.rs index c8a9fec..66947cf 100644 --- a/src/main.rs +++ b/spider/src/lib.rs @@ -113,7 +113,7 @@ fn format_response<'a>(response: Response) -> &'a [u8] { return buf; } -fn handle_client(stream: TcpStream) { +pub fn handle_client(stream: TcpStream) { let mut buf: [u8; 1024] = [0; 1024]; stream.peek(&mut buf).expect("Couldn't read from socket"); @@ -136,13 +136,3 @@ fn handle_client(stream: TcpStream) { let response = format_response(response); } -fn main() -> std::io::Result<()> { - let listener = TcpListener::bind("localhost:3000")?; - - // accept connections and process them serially - for stream in listener.incoming() { - handle_client(stream?); - } - - Ok(()) -} |