Function choices::warp::filters::fs::dir [−][src]
pub fn dir(path: impl Into<PathBuf>) -> impl FilterClone
Creates a Filter
that serves a directory at the base path
joined
by the request path.
This can be used to serve “static files” from a directory. By far the most
common pattern of serving static files is for GET
requests, so this
filter automatically includes a GET
check.
Example
use warp::Filter; // Matches requests that start with `/static`, // and then uses the rest of that path to lookup // and serve a file from `/www/static`. let route = warp::path("static") .and(warp::fs::dir("/www/static")); // For example: // - `GET /static/app.js` would serve the file `/www/static/app.js` // - `GET /static/css/app.css` would serve the file `/www/static/css/app.css`