pub fn serve_as_file_path<T>(
    directory_path: &'static str
) -> impl Fn(Request, Arc<T>) -> Response
Expand description

Treat the request URI as a file path relative to the given directory and serve files from there.

Examples

  • directory path of . will serve files relative to the current directory
  • directory path of ./static will serve files from the static directory but with their whole URI, for example a request to /images/ferris.png will map to the file ./static/images/ferris.png.

This is not equivalent to serve_dir, as serve_dir respects index files within nested directories.