warp
warp copied to clipboard
Implement `warp::reply::file` for dynamic file service
This pull request implements warp::reply::file
, warp::header::conditionals
, and publishes warp::header::Conditionals
. I also internally moves Conditionals to what I believe is a more fitting place (from fs to header).
Fixes https://github.com/seanmonstar/warp/issues/171 Supersedes https://github.com/seanmonstar/warp/pull/924
Awesome work, thanks! I think I have mainly one suggestion: make Conditionals
optional. reply::file(path)
could return File
, which has an inherent method conditionals()
that takes the conditional arguments. What do you think?
I'm not sure that's very feasible since we return a future dependent on the value initially passed in. We could have a reply::conditional_file though
I've been using Molkar's version for a while now, and it works perfectly for my needs. How can we make this PR land into the main version?
Any updates here? I'd love to have this feature
Any updates here? I'd love to have this feature
same
I'd independently hit this very issue when trying to build a file server that couldn't serve files. I'd imagined that warp would have the building blocks available to allow DIYing this, but AFAICT the only solution right now is to copy/paste a bunch of pub(crate)
code out of warp. I got pretty far in doing that, but realized that the exercise had become more hassle than it was worth.
If anyone else stumbles upon this issue after hitting a brick wall like I had, I ended up just switching to using this instead: https://api.rocket.rs/master/rocket/fs/struct.FileServer.html