Comments (4)
Ohhh OK, so this isn't to try to just tweak some content as it streams by, you'd like to map the path to a static file, but after that, create a whole different Response
using the contents of that file...
In your case, you'd want to buffer the full contents in memory, but people probably wouldn't want that with bigger files. Perhaps this could be handled by adding a new Filter
to warp::fs
, which doesn't try to reply with the file, but instead provides you with the tokio_fs::File
so you can do whatever you want with it?
from warp.
Can you say more about what you hope to do it? The exact type of streaming bodies hasn't been exposed yet, as I want to be able to add automatic compression support, and currently worry that might require changes, which would need a breaking change.
That said, mapping the streaming body chunks does seem useful. Possibly using with
, or something?
let route = warp::fs::dir("static")
.with(warp::reply::with::map_body(|buf: impl Buf| {
// return a new `impl Buf` instead
}));
from warp.
I was thinking something along the lines of: I have a blog that uses a template file for a page, based on what the users request I retrieve a text file (via warp::fs::dir) and then use the string of that file to render the template with the post's contents.
from warp.
That sounds like it would work perfectly!
from warp.
Related Issues (20)
- Clarify API docs around multipart forms HOT 2
- Feature request: More customization points in tracing HOT 2
- EC Private key support HOT 1
- Make `Option<F>` a filter when F is a filter
- Feature request: `warp::make_service()` or `warp::service_with_addr()`
- CVE-2023-43669/GHSA-9mcr-873m-xcxp: tungstenite <= 0.20.0 DoS vulnerability HOT 1
- [feature request] [low prio] Non-Metal fallback option HOT 2
- SSE gives up on Streams that return Pending HOT 3
- Server::run should return ! (never type)
- Default OS / self signed certificate without create it HOT 1
- websocket disconnect (code: 1006, reason: "") HOT 2
- Add `rust-version` into `Cargo.toml` HOT 1
- Error `connection closed before message completed` after 60s HOT 2
- Websocket connection closes immediately, but not with firefox HOT 4
- Navigation between panes using vim commands HOT 1
- examples/tls/cert.pem has expired
- Upgrade to hyper v1 HOT 4
- key contains no private key while using ecc key HOT 1
- integrate with monoio
- HELP: filters inside .then never get executed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from warp.