Crate http_dir

Source
Expand description

HTTP file server, to access files on the [Filesystem]. User can implement own [Filesystem], also can use DiskFilesystem or IncludeDirFilesystem directly

§Note

This crate require TAIT feature, it will be stable soon but now it is a nightly feature

§Example

use http_dir::ServeDir;
use http_dir::fs::disk::DiskFilesystem;

// This will serve files in the "assets" directory and
// its subdirectories
let service = ServeDir::new(DiskFilesystem::from("assets"));

// Run our service using `hyper`
let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
hyper::Server::bind(&addr)
    .serve(tower::make::Shared::new(service))
    .await
    .expect("server error");

Modules§

fs
Allow user implement own filesystem, to provide file for the ServeDir

Structs§

DefaultServeDirFallback
The default fallback service used with ServeDir.
ServeDir
Service that serves files from a given directory and all its sub directories.
ServeFile
Service that serves a file

Type Aliases§

ResponseBody