Struct staticfile::Static
[-] [+]
[src]
pub struct Static { pub root: PathBuf, }
The static file-serving Handler
.
This handler serves files from a single filesystem path, which may be absolute or relative.
Incoming requests are mapped onto the filesystem by appending their URL path to the handler's
root path. If the filesystem path corresponds to a regular file, the handler will attempt to
serve it. Otherwise, if the path corresponds to a directory containing an index.html
,
the handler will attempt to serve that instead.
Errors
If the path doesn't match any real object in the filesystem, the handler will return
a Response with status::NotFound
. If an IO error occurs whilst attempting to serve
a file, FileError(IoError)
will be returned.
Fields
root | The path this handler is serving files from. |
Methods
impl Static
fn new<P: AsRef<Path>>(root: P) -> Static
Create a new instance of Static
with a given root path.
If Path::new("")
is given, files will be served from the current directory.