Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "webdav-handler"
# - Update CHANGELOG.md.
# - Run ./generate-readme
# - Create git tag v0.x.y
version = "0.2.0"
version = "0.2.2"

readme = "README.md"
description = "handler for the HTTP and Webdav protocols with filesystem backend"
Expand Down
22 changes: 19 additions & 3 deletions src/warp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,29 @@ pub fn dav_handler(handler: DavHandler) -> BoxedFilter<(impl Reply,)> {
/// The behaviour for serving a directory depends on the flags:
///
/// - `index_html`: if an `index.html` file is found, serve it.
/// - `auto_index`: create a directory listing.
/// - `auto_index_over_get`: Create a directory index page when accessing over HTTP `GET` (but NOT
/// affecting WebDAV `PROPFIND` method currently). In the current implementation, this only
/// affects HTTP `GET` method (commonly used for listing the directories when accessing through a
/// `http://` or `https://` URL for a directory in a browser), but NOT WebDAV listing of a
/// directory (HTTP `PROPFIND`). BEWARE: The name and behaviour of this parameter variable may
/// change, and later it may control WebDAV `PROPFIND`, too (but not as of now).
///
/// In release mode, if `auto_index_over_get` is `true`, then this executes as described above
/// (currently affecting only HTTP `GET`), but beware of this current behaviour.
///
/// In debug mode, if `auto_index_over_get` is `false`, this _panics_. That is so that it alerts
/// the developers to this current limitation, so they don't accidentally expect
/// `auto_index_over_get` to control WebDAV.
/// - no flags set: 404.
pub fn dav_dir(base: impl AsRef<Path>, index_html: bool, auto_index: bool) -> BoxedFilter<(impl Reply,)> {
pub fn dav_dir(base: impl AsRef<Path>, index_html: bool, auto_index_over_get: bool) -> BoxedFilter<(impl Reply,)> {
debug_assert!(
auto_index_over_get,
"See documentation of webdav_handler::warp::dav_dir(...)."
);
let mut builder = DavHandler::builder()
.filesystem(LocalFs::new(base, false, false, false))
.locksystem(FakeLs::new())
.autoindex(auto_index);
.autoindex(auto_index_over_get);
if index_html {
builder = builder.indexfile("index.html".to_string())
}
Expand Down