Function warp::filters::fs::file

source ·
pub fn file(
    path: impl Into<PathBuf>,
) -> impl FilterClone<Extract = (File,), Error = Rejection>
Expand description

Creates a Filter that serves a File at the path.

Does not filter out based on any information of the request. Always serves the file at the exact path provided. Thus, this can be used to serve a single file with GETs, but could also be used in combination with other filters, such as after validating in POST request, wanting to return a specific file as the body.

For serving a directory, see dir.

§Example

// Always serves this file from the file system.
let route = warp::fs::file("/www/static/app.js");