Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat examples: add rocket dynamic template (shuttle-static-folder) example #38

Conversation

jhawkesworth
Copy link
Contributor

This PR adds 2 example projects to the existing rocket examples, one for showing how to serve static files using shuttle-static-folder and Rocket's FileServ and the other to demonstrate how to use Rocket's dynamic templates mechanism (also needs shuttle-static-folder).

Once there are suitable examples I think shuttle-hq/shuttle#763 can be closed.

@jhawkesworth
Copy link
Contributor Author

last change just modified a code comment which wasn't actually true. I think this is done now so ready for review.

@jhawkesworth jhawkesworth changed the title feat examples: add rocket static files and dynamic template examples feat examples: add rocket dynamic template (shuttle-static-folder) example Apr 19, 2023
Copy link
Contributor

@oddgrd oddgrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jhawkesworth! 🥳 This looks good to me, just missing a few commented out lines and a rustfmt run (which reminds me we should set up some basic CI for this repo).

@@ -0,0 +1,42 @@
#[macro_use]
extern crate rocket;
// use rocket::fs::{FileServer, relative};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// use rocket::fs::{FileServer, relative};

let figment = rocket::Config::figment()
.merge(("template_dir", template_dir));
let rocket = rocket::custom(figment)
// .mount("/", FileServer::from(relative!("templates")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// .mount("/", FileServer::from(relative!("templates")))

rocket/dyn_template_hbs/src/main.rs Outdated Show resolved Hide resolved
@jhawkesworth
Copy link
Contributor Author

jhawkesworth commented Apr 19, 2023 via email

@jhawkesworth
Copy link
Contributor Author

@oddgrd I formatted the code but left the commented out use of FileServ (with explanatory comment). Hope that's ok. If you don't like it, just go ahead and take L3-4 and L40-41 out of src/main.rs. But I ran a test just now and rocket won't serve a favicon for example from the location configured as template_dir without FileServ mount. None of the other rocket examples show how to use FileServ for serving static content, so I think it is a reasonable thing to have an example to demonstrate.

@oddgrd
Copy link
Contributor

oddgrd commented Apr 20, 2023

Okay, that's fine. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants