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

@@ -68,7 +68,7 @@ func newServer(f fs.Fs, opt *httplib.Options) *server {
f: f,
vfs: vfs.New(f, &vfsflags.Opt),
}
mux.HandleFunc("/", s.handler)
mux.HandleFunc(s.Opt.Prefix+"/", s.handler)
return s
}
@@ -93,7 +93,10 @@ func (s *server) handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Accept-Ranges", "bytes")
w.Header().Set("Server", "rclone/"+fs.Version)
urlPath := r.URL.Path
urlPath, ok := s.Path(w, r)
if !ok {
return
}
isDir := strings.HasSuffix(urlPath, "/")
remote := strings.Trim(urlPath, "/")
if isDir {