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()
}
});
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for File
impl !RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl !UnwindSafe for File
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more