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

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

Structs

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

Type Definitions