pub struct File { /* private fields */ }
Expand description

A file response.

Implementations

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

Formats the value using the given formatter. Read more

Converts the given value into a Response. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.