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/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/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/demo/demo.example.json b/demo/demo.example.json new file mode 100644 index 0000000..c8f9f21 --- /dev/null +++ b/demo/demo.example.json @@ -0,0 +1,6 @@ +{ + "directory": "./", + "host_and_port": "127.0.0.1:3000", + "content_encodings": ["zstd"], + "filepath_404": "./404.html" +} 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" -} 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}