Closed Folyd closed 2 years ago
What does "make the Dir
tower compatible" mean?
What i mean is this:
// This will serve files in the "assets" directory and
// its subdirectories
- let service = ServeDir::new("assets");
+ let service: Dir<'_> = include_dir::include_dir!("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");
You will need create your own tower-include-dir
crate which exposes a tower::Service
implementation backed by include_dir::Dir
. This is outside the scope of the include_dir
project.
Ok, I see. It's possible to make this under the tower
feature flag in this crate? If so, I can file a PR. ^^-
It sounds like this is functionality you care about, so I would encourage you to publish your own tower-include-dir
crate. I don't want to add it under a feature flag because that's extra maintenance work for me and it would tie include_dir
's versioning to tower
(e.g. when I publish include_dir v1.0
, I'll need to make another major release when tower
goes from 0.4
to 0.5
).
tower-http
provides a handy ServeDir to serve directory HTTP requests. I think we can also make theDir
tower compatible?