pub struct File { /* private fields */ }Expand description
A file response.
Implementations§
source§impl File
impl File
sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Extract the &Path of the file this Response delivers.
Example
The example below changes the Content-Type response header for every file called video.mp4.
use warp::{Filter, reply::Reply};
let route = warp::path("static")
.and(warp::fs::dir("/www/static"))
.map(|reply: warp::filters::fs::File| {
if reply.path().ends_with("video.mp4") {
warp::reply::with_header(reply, "Content-Type", "video/mp4").into_response()
} else {
reply.into_response()
}
});