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

Serving static files #2866

Open
2 tasks done
giuliohome opened this issue Sep 21, 2024 · 1 comment
Open
2 tasks done

Serving static files #2866

giuliohome opened this issue Sep 21, 2024 · 1 comment
Labels
docs Improvements or additions to documentation

Comments

@giuliohome
Copy link

giuliohome commented Sep 21, 2024

What kind of documentation problem are you reporting?

Unclear Docs

Where is the issue found?

https://api.rocket.rs/v0.5/rocket/fs/struct.FileServer#relative-paths

What's wrong?

I encountered an issue serving a static HTML template after deploying it with Docker containerization and I think that the documentation is a bit unclear.

Let me quote it first

In the example above, /static is an absolute path. If your static files are stored relative to your crate and your project is managed by Rocket, use the relative! macro to obtain a path that is relative to your crate’s root.

Actually relative!("static") seems to produce an absolute path out of the relative one, so finally I had to omit the relative! even though it was counter-intuitive.

System Checks

  • I confirmed that the issue still exists on master on GitHub.
  • I was unable to find a previous report of this problem.
@giuliohome giuliohome added the docs Improvements or additions to documentation label Sep 21, 2024
giuliohome added a commit to giuliohome/rust-rocket-playground that referenced this issue Sep 21, 2024
@giuliohome
Copy link
Author

As I noted here, this comment of @blackghost1987 should be included in the documentation:

The relative! macro has a confusing name. If you want your binary to find the static dir relative to your binary (so you can deploy it anywhere) then you should get rid of relative!, because it would bake in the absolute path. Just use something like FileServer::from("static"), it should work fine.

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

No branches or pull requests

1 participant