From 113b79c0459f3e5b91c4aea19d270666b338c6ff Mon Sep 17 00:00:00 2001 From: Matthew Pomes Date: Sun, 30 Jun 2024 18:29:00 -0500 Subject: [PATCH] Update examples and docs to use the new FileServer api --- core/lib/src/fs/mod.rs | 2 +- docs/guide/05-requests.md | 2 +- docs/guide/11-deploying.md | 2 +- examples/chat/src/main.rs | 2 +- examples/forms/src/main.rs | 2 +- examples/static-files/src/main.rs | 2 +- examples/static-files/src/tests.rs | 2 +- examples/todo/src/main.rs | 2 +- examples/upgrade/src/main.rs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/lib/src/fs/mod.rs b/core/lib/src/fs/mod.rs index f5301422d6..18f5f06200 100644 --- a/core/lib/src/fs/mod.rs +++ b/core/lib/src/fs/mod.rs @@ -34,7 +34,7 @@ crate::export! { /// /// #[launch] /// fn rocket() -> _ { - /// rocket::build().mount("/", FileServer::from(relative!("static"))) + /// rocket::build().mount("/", FileServer::new(relative!("static"))) /// } /// ``` /// diff --git a/docs/guide/05-requests.md b/docs/guide/05-requests.md index 838cbb12df..08a0329df0 100644 --- a/docs/guide/05-requests.md +++ b/docs/guide/05-requests.md @@ -169,7 +169,7 @@ async fn files(file: PathBuf) -> Option { fn rocket() -> _ { rocket::build() // serve files from `/www/static` at path `/public` - .mount("/public", FileServer::from("/www/static")) + .mount("/public", FileServer::new("/www/static")) } ``` diff --git a/docs/guide/11-deploying.md b/docs/guide/11-deploying.md index 5afd18982b..245683ccec 100644 --- a/docs/guide/11-deploying.md +++ b/docs/guide/11-deploying.md @@ -49,7 +49,7 @@ For any deployment, it's important to keep in mind: #[launch] fn rocket() -> _ { rocket::build() - .mount("/", FileServer::from("./static")) + .mount("/", FileServer::new("./static")) .attach(Template::fairing()) } ``` diff --git a/examples/chat/src/main.rs b/examples/chat/src/main.rs index 0a2f68d5c9..eab8abe1ee 100644 --- a/examples/chat/src/main.rs +++ b/examples/chat/src/main.rs @@ -54,5 +54,5 @@ fn rocket() -> _ { rocket::build() .manage(channel::(1024).0) .mount("/", routes![post, events]) - .mount("/", FileServer::from(relative!("static"))) + .mount("/", FileServer::new(relative!("static"))) } diff --git a/examples/forms/src/main.rs b/examples/forms/src/main.rs index a908eb4705..5953403a34 100644 --- a/examples/forms/src/main.rs +++ b/examples/forms/src/main.rs @@ -93,5 +93,5 @@ fn rocket() -> _ { rocket::build() .mount("/", routes![index, submit]) .attach(Template::fairing()) - .mount("/", FileServer::from(relative!("/static"))) + .mount("/", FileServer::new(relative!("/static"))) } diff --git a/examples/static-files/src/main.rs b/examples/static-files/src/main.rs index 53c4270876..7b94e7dfc7 100644 --- a/examples/static-files/src/main.rs +++ b/examples/static-files/src/main.rs @@ -23,5 +23,5 @@ mod manual { fn rocket() -> _ { rocket::build() .mount("/", rocket::routes![manual::second]) - .mount("/", FileServer::from(relative!("static"))) + .mount("/", FileServer::new(relative!("static"))) } diff --git a/examples/static-files/src/tests.rs b/examples/static-files/src/tests.rs index 59c0ceca37..824e157f48 100644 --- a/examples/static-files/src/tests.rs +++ b/examples/static-files/src/tests.rs @@ -63,7 +63,7 @@ fn test_icon_file() { #[test] fn test_invalid_path() { - test_query_file("/hidden", None, Status::PermanentRedirect); + test_query_file("/hidden", None, Status::TemporaryRedirect); test_query_file("/thou_shalt_not_exist", None, Status::NotFound); test_query_file("/thou/shalt/not/exist", None, Status::NotFound); test_query_file("/thou/shalt/not/exist?a=b&c=d", None, Status::NotFound); diff --git a/examples/todo/src/main.rs b/examples/todo/src/main.rs index a12f7ab439..b641162435 100644 --- a/examples/todo/src/main.rs +++ b/examples/todo/src/main.rs @@ -110,7 +110,7 @@ fn rocket() -> _ { .attach(DbConn::fairing()) .attach(Template::fairing()) .attach(AdHoc::on_ignite("Run Migrations", run_migrations)) - .mount("/", FileServer::from(relative!("static"))) + .mount("/", FileServer::new(relative!("static"))) .mount("/", routes![index]) .mount("/todo", routes![new, toggle, delete]) } diff --git a/examples/upgrade/src/main.rs b/examples/upgrade/src/main.rs index 7526b5b155..c9a69bd3f2 100644 --- a/examples/upgrade/src/main.rs +++ b/examples/upgrade/src/main.rs @@ -39,5 +39,5 @@ fn echo_raw(ws: ws::WebSocket) -> ws::Stream!['static] { fn rocket() -> _ { rocket::build() .mount("/", routes![echo_channel, echo_stream, echo_raw]) - .mount("/", FileServer::from(fs::relative!("static"))) + .mount("/", FileServer::new(fs::relative!("static"))) }