We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
when using SpaRouter, it needs a real dir in the fs, however, sometimes the resources may include in the binary by something like include_dir!.
SpaRouter
include_dir!
If SpaRouter allows using a virtual dir to access the resources, it will increase the practical
maybe SpaRouter can provide a trait like
trait VirtualDir { type VirtualFile: AsyncRead + AsyncWrite + AsyncSeek + Unpin + Send + 'static; type VirtualFilenameStream: Stream<Item=io::Result<PathBuf>> + Unpin + Send + 'static; async fn open_file(&self, name: &str) -> io::Result<Self::VirtualFile>; async fn list_files(&self, dir: &str) -> io::Result<Self::VirtualFilenameStream>; }
to allow user pass a virtual dir to the SpaRouter
user can also try to write the file data to a tmp dir and let SpaRouter access them, but I don't think this way is a good idea
The text was updated successfully, but these errors were encountered:
This is something we're already working on in tower-http. See tower-rs/tower-http#309 and tower-rs/tower-http#313.
How exactly that'll be integrated into SpaRouter is unclear but until its landed in tower-http there isn't much we can do.
I'm actually considering removing SpaRouter all together since ServeDir is soon gonna be easier to use (thanks to tower-rs/tower-http#283). It is also more flexible (see https://github.com/tokio-rs/axum/blob/main/examples/static-file-server/src/main.rs). But thats a separate discussion of course. Though I think I'll close this issue for now. Feel free to ask follow up questions though :)
ServeDir
Sorry, something went wrong.
made a small POC with include_dir https://dev.to/konstantin/bundle-frontend-with-axum-build-using-includedir-g8i
include_dir
No branches or pull requests
Feature Request
Motivation
when using
SpaRouter
, it needs a real dir in the fs, however, sometimes the resources may include in the binary by something likeinclude_dir!
.If
SpaRouter
allows using a virtual dir to access the resources, it will increase the practicalProposal
maybe
SpaRouter
can provide a trait liketo allow user pass a virtual dir to the
SpaRouter
Alternatives
user can also try to write the file data to a tmp dir and let
SpaRouter
access them, but I don't think this way is a good ideaThe text was updated successfully, but these errors were encountered: