-
Notifications
You must be signed in to change notification settings - Fork 321
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
Allow the routing methods to open a static file #63
Comments
Currently, middleware don't have any access to the Looking at how it is done in rocket and actix, it seems that they are following something similar, both of them having internal configuration, rather than modifying shared configuration. |
Maybe this feature could be implemented via let mut app = tide::App::new(());
app.at("/static/*").get(StaticFileEndpoint {
root_path: PathBuf::from("./static/content/web"),
suffix: ".html".to_string(), // maybe more configuration
});
let address = "127.0.0.1:8000".to_owned();
println!("Server is listening on http://{}", address);
app.serve(address) |
I implemented something with an API in the same vein as what @DCjanus suggested. It is going to need a lot more configuration options, but it already works. Here's the repo: https://github.com/tomhoule/tide-static-files |
Great job for @tomhoule, but for prod, there is still a lot of other work to be done. For example:
I was working on this too, but recently, I got a lot of job to be done, may not be able to complete this work. For |
Thanks! Indeed, there's a lot of work ahead. I wanted to release early to get some feedback and not pour too much work into something that nobody will use. The three points you listed seem important, among others. Do you want to open issues for them? (otherwise I can do it of course). |
@tomhoule My English is terrible, it's too hard to open such issue for me. 😭 |
No worries, I can do it :) Feel free to open issues just to drop ideas without explaining at length, that helps a lot too. edit: issues in other languages are ok too (I can read chinese) |
I was going to develop such Endpoint in tide, so I forked tide and pushed some code to dcjanus/tide. And then, inspired by tomhoule, separated repo might be better. So I moved my code from dcjanus/tide to dcjanus/tide-static-file. PS: new repo inspired a lot from @tomhoule |
I think we should join efforts on one crate. @DCjanus has more features so we could use this crate as a starting point. I read the implementation and it looks like it's using blocking file operations without a thread pool, though, so that should probably be fixed. |
I can contribute this part if we decide to standardize on this crate. |
To be honest, for me, this repo is just for fun. |
With the latest changes in the revamp PR it became possible to make tide-static-files work again with the new abstractions. |
from what I understand, this issue is about serving a single file from within an endpoint, correct? Tide now supports serving static files under a directory... app.at("/public/images").serve_dir("images/")?; but maybe there's potentially a case where a user would actually want to handle this within an endpoint. |
Isn't this covered with the |
Yeah I think this is probably covered by #725 |
P.S. Something similar to Rocket's NamedFile
The text was updated successfully, but these errors were encountered: