diff --git a/Cargo.lock b/Cargo.lock index 944a118..63b5a0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1187,7 +1187,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "url", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index eec0c87..82f4398 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,5 +8,4 @@ rocket = {path = "../Rocket/core/lib"} tokio = { version = "1.40.0", features = ["full"] } tracing = "0.1.40" tracing-subscriber = "0.3.18" -url = "2.5.2" minio = {git="https://github.com/minio/minio-rs.git", rev = "c28f576"} diff --git a/src/main.rs b/src/main.rs index 04f2c19..3a82b06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ use rocket::{fairing::{Fairing, Info, Kind}, fs::FileServer, get, http::Header, routes, Request, Response, State}; use s3::S3; use tracing::{info, Level}; -use url::Url; mod s3; @@ -21,7 +20,7 @@ async fn main() { .init(); let config = Config { - s3_bucket: "v1.10", + s3_bucket: "b64v1", s3_url: "http://localhost:9000", s3_access_key: "8UO76z8wCs9DnpxSbQUY", s3_secret_key: "xwKVMpf2jzgprsdo85Dvo74UmO84y0aRrAUorYY5", @@ -42,14 +41,12 @@ async fn main() { } #[get("/s3/")] -async fn get_s3_content(path: &str, db: &State) -> String { - info!(path); - // TODO this is just pseudo-code - let url = "en.wikipedia.org/wiki/CNBC"; - if let Some(resp) = db.get(&url).await { - return resp +async fn get_s3_content(path: &str, db: &State) -> Option { + if let Some(resp) = db.get(&path).await { + return Some(resp) } - "Hello world.".to_owned() + // instead of some/none I would rather this be 200/404 + None } // CORS, to allow other sites to request this from their front-end @@ -69,5 +66,7 @@ impl Fairing for CORS { response.set_header(Header::new("Access-Control-Allow-Methods", "POST, GET, PATCH, OPTIONS")); response.set_header(Header::new("Access-Control-Allow-Headers", "*")); response.set_header(Header::new("Access-Control-Allow-Credentials", "true")); + // TODO set this automatically like how Rocket/core/lib/src/fs/server.rs does (bottom of file) + response.set_header(Header::new("Content-Type", "text/html")); } }