From 0918d5d0dc77765e5441b24e5a45750afa33fa46 Mon Sep 17 00:00:00 2001 From: Taylor Vann Date: Tue, 29 Jul 2025 20:13:44 -0700 Subject: [PATCH 1/3] remove config workspace module --- Cargo.toml | 2 +- config/Cargo.toml | 11 ----------- file_server/Cargo.toml | 4 ---- config/src/lib.rs => file_server/src/config.rs | 0 file_server/src/main.rs | 4 ++-- file_server/src/service.rs | 2 +- response/Cargo.toml | 2 -- 7 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 config/Cargo.toml rename config/src/lib.rs => file_server/src/config.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 1f2096e..b3045d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["config", "file_server", "response"] +members = ["file_server", "response"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/config/Cargo.toml b/config/Cargo.toml deleted file mode 100644 index 80a7358..0000000 --- a/config/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "config" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde_json = { workspace = true} -serde = { workspace = true} -tokio = { workspace = true} diff --git a/file_server/Cargo.toml b/file_server/Cargo.toml index 69395cd..6015820 100644 --- a/file_server/Cargo.toml +++ b/file_server/Cargo.toml @@ -6,10 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bytes = { workspace = true} -config = { path = "../config" } -futures-util = { workspace = true} -http-body-util = { workspace = true} hyper-util = { workspace = true} hyper = { workspace = true} response = { path = "../response" } diff --git a/config/src/lib.rs b/file_server/src/config.rs similarity index 100% rename from config/src/lib.rs rename to file_server/src/config.rs diff --git a/file_server/src/main.rs b/file_server/src/main.rs index dcee119..7cf1349 100644 --- a/file_server/src/main.rs +++ b/file_server/src/main.rs @@ -4,10 +4,10 @@ use std::env; use std::path::PathBuf; use tokio::net::TcpListener; -use config; +mod config; mod service; -use crate::config::Config; +use config::Config; #[tokio::main] async fn main() -> Result<(), String> { diff --git a/file_server/src/service.rs b/file_server/src/service.rs index a3b9827..778e2bf 100644 --- a/file_server/src/service.rs +++ b/file_server/src/service.rs @@ -4,7 +4,7 @@ use hyper::Request; use std::future::Future; use std::pin::Pin; -use config::Config; +use crate::config::Config; /* BoxedResponse is a type. It should work with hyper responses across diff --git a/response/Cargo.toml b/response/Cargo.toml index d46e63f..9372643 100644 --- a/response/Cargo.toml +++ b/response/Cargo.toml @@ -11,7 +11,5 @@ futures-util = { workspace = true} http-body-util = { workspace = true} hyper-util = { workspace = true} hyper = { workspace = true} -serde_json = { workspace = true} -serde = { workspace = true} tokio-util = { workspace = true} tokio = { workspace = true} From 29314dcffd2fedd96f06b7ea06654af39512b08e Mon Sep 17 00:00:00 2001 From: Taylor Vann Date: Tue, 29 Jul 2025 20:18:40 -0700 Subject: [PATCH 2/3] add demo config to demo dir --- demo/demo_config.example.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 demo/demo_config.example.json diff --git a/demo/demo_config.example.json b/demo/demo_config.example.json new file mode 100644 index 0000000..c8f9f21 --- /dev/null +++ b/demo/demo_config.example.json @@ -0,0 +1,6 @@ +{ + "directory": "./", + "host_and_port": "127.0.0.1:3000", + "content_encodings": ["zstd"], + "filepath_404": "./404.html" +} From 485e4e87bd739fcc9ff094c4f53bed763b98dde7 Mon Sep 17 00:00:00 2001 From: Taylor Vann Date: Tue, 29 Jul 2025 20:27:57 -0700 Subject: [PATCH 3/3] update readme with demo config --- README.md | 8 ++++---- demo/{demo_config.example.json => demo.example.json} | 0 file_server.example.json | 6 ------ 3 files changed, 4 insertions(+), 10 deletions(-) rename demo/{demo_config.example.json => demo.example.json} (100%) delete mode 100644 file_server.example.json diff --git a/README.md b/README.md index 62bcbd8..8c488b8 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The `content_encodings` and `filepath_404` properties are optional. Bash the following command to serve files based on a an example configuration: ```sh -file_server file_server/file_server.example.json +file_server demo/demo.example.json ``` Open a browser and visit `http://localhost:3000` and an encoded version of `index.html` will be delivered. @@ -77,8 +77,8 @@ Accept-Encoding: gzip; And the source file has a correspponding gziped file: ```sh -./www/index.html # source file -./www/index.html.gz # gzipped file +index.html # source file +index.html.gz # gzipped file ``` `File_server` will send the encoded file, if available. Otherwise, it serves the source file. @@ -105,6 +105,6 @@ Multipart ranges are not currently supported. Multipart ranges are memory hogs and difficult to deliver efficiently without abusing memory resources. -## Licence +## License `File_server` is released under the BSD 3-Clause License. diff --git a/demo/demo_config.example.json b/demo/demo.example.json similarity index 100% rename from demo/demo_config.example.json rename to demo/demo.example.json diff --git a/file_server.example.json b/file_server.example.json deleted file mode 100644 index b142b55..0000000 --- a/file_server.example.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "directory": "./demo", - "host_and_port": "127.0.0.1:3000", - "content_encodings": ["gzip", "deflate", "br", "zstd"], - "filepath_404": "./demo/404.html" -}