http_dir/
lib.rs

1#![feature(impl_trait_in_assoc_type)]
2
3//! HTTP file server, to access files on the [`Filesystem`]. User can implement own [`Filesystem`],
4//! also can use [`DiskFilesystem`](fs::disk::DiskFilesystem) or
5//! [`IncludeDirFilesystem`](fs::include_dir::IncludeDirFilesystem) directly
6//!
7//! # Note
8//!
9//! This crate require [TAIT](https://github.com/rust-lang/rust/issues/63063) feature, it will be
10//! stable soon but now it is a nightly
11//! feature
12//!
13//! # Example
14//! ```
15//! use http_dir::ServeDir;
16//! use http_dir::fs::disk::DiskFilesystem;
17//!
18//! // This will serve files in the "assets" directory and
19//! // its subdirectories
20//! let service = ServeDir::new(DiskFilesystem::from("assets"));
21//!
22//! # async {
23//! // Run our service using `hyper`
24//! let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 3000));
25//! hyper::Server::bind(&addr)
26//!     .serve(tower::make::Shared::new(service))
27//!     .await
28//!     .expect("server error");
29//! # };
30//! ```
31
32use std::io;
33
34use bytes::Bytes;
35use http_body::combinators::UnsyncBoxBody;
36pub use serve_dir::{DefaultServeDirFallback, ServeDir};
37pub use serve_file::ServeFile;
38
39mod async_body;
40mod content_encoding;
41pub mod fs;
42mod headers;
43mod open_file;
44mod serve_dir;
45mod serve_file;
46#[cfg(test)]
47mod tests;
48
49pub type ResponseBody = UnsyncBoxBody<Bytes, io::Error>;