1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

serve http/webdav/restic: implement --prefix - fixes #3398

--prefix enables the servers to serve from a non root prefix.  This
enables easier proxying.
This commit is contained in:
Nick Craig-Wood
2019-08-04 10:56:38 +01:00
parent d51a970932
commit 02eb747d71
5 changed files with 51 additions and 7 deletions

View File

@@ -114,18 +114,22 @@ func newWebDAV(f fs.Fs, opt *httplib.Options) *WebDAV {
f: f,
vfs: vfs.New(f, &vfsflags.Opt),
}
w.Server = httplib.NewServer(http.HandlerFunc(w.handler), opt)
webdavHandler := &webdav.Handler{
Prefix: w.Server.Opt.Prefix,
FileSystem: w,
LockSystem: webdav.NewMemLS(),
Logger: w.logRequest, // FIXME
}
w.webdavhandler = webdavHandler
w.Server = httplib.NewServer(http.HandlerFunc(w.handler), opt)
return w
}
func (w *WebDAV) handler(rw http.ResponseWriter, r *http.Request) {
urlPath := r.URL.Path
urlPath, ok := w.Path(rw, r)
if !ok {
return
}
isDir := strings.HasSuffix(urlPath, "/")
remote := strings.Trim(urlPath, "/")
if !disableGETDir && (r.Method == "GET" || r.Method == "HEAD") && isDir {