feat(web): Add WebDAV endpoint to web server (Port 11438)
This commit is contained in:
BIN
data/auth.sqlite
BIN
data/auth.sqlite
Binary file not shown.
@@ -4,9 +4,11 @@ use axum::{
|
||||
extract::{Path, Query, State},
|
||||
http::{HeaderMap, StatusCode},
|
||||
response::{Html, IntoResponse, Json},
|
||||
routing::{delete, get, patch, post, put},
|
||||
routing::{any, delete, get, patch, post, put},
|
||||
Extension,
|
||||
Router,
|
||||
};
|
||||
use dav_server::{fakels::FakeLs, DavHandler};
|
||||
use serde::Deserialize;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
@@ -132,6 +134,26 @@ pub async fn run(port: u16, file: Option<String>) -> anyhow::Result<()> {
|
||||
}
|
||||
});
|
||||
|
||||
// WebDAV handler creation (Phase 20)
|
||||
let webdav_user = "demo";
|
||||
let webdav_home = std::path::PathBuf::from("/Users/accusys/momentry/var/sftpgo/data").join(webdav_user);
|
||||
|
||||
let webdav_vfs = Box::new(crate::vfs::local_fs::LocalFs::new());
|
||||
let webdav_fs = crate::webdav::VfsDavFs::new(
|
||||
webdav_vfs,
|
||||
webdav_home,
|
||||
None, // upload_hook
|
||||
webdav_user.to_string(),
|
||||
);
|
||||
|
||||
let webdav_handler = DavHandler::builder()
|
||||
.filesystem(webdav_fs)
|
||||
.locksystem(FakeLs::new())
|
||||
.strip_prefix("/webdav")
|
||||
.build_handler();
|
||||
|
||||
log::info!("WebDAV handler created for user: {}", webdav_user);
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(root_handler))
|
||||
.route("/display", post(display_handler))
|
||||
@@ -234,6 +256,11 @@ pub async fn run(port: u16, file: Option<String>) -> anyhow::Result<()> {
|
||||
.route("/files", get(|| async { Html(include_str!("file_list.html")) }))
|
||||
.route("/products", get(|| async { Html(include_str!("product_manager.html")) }))
|
||||
.route("/downloads", get(|| async { Html(include_str!("category_view.html")) }))
|
||||
// WebDAV API endpoints (Phase 20)
|
||||
.route("/webdav", any(handle_webdav))
|
||||
.route("/webdav/", any(handle_webdav))
|
||||
.route("/webdav/*path", any(handle_webdav))
|
||||
.layer(Extension(webdav_handler))
|
||||
.layer(DefaultBodyLimit::disable())
|
||||
.with_state(state);
|
||||
|
||||
@@ -2418,3 +2445,11 @@ async fn search_files_handler(Query(query): Query<SearchQuery>) -> impl IntoResp
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
// WebDAV handler (Phase 20)
|
||||
async fn handle_webdav(
|
||||
Extension(dav): Extension<DavHandler>,
|
||||
req: axum::extract::Request,
|
||||
) -> impl IntoResponse {
|
||||
dav.handle(req).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user