1
mirror of https://github.com/rclone/rclone synced 2024-11-28 06:41:41 +01:00

rcd: prefix patch for rcd and web-gui

This commit is contained in:
Chaitanya 2019-08-21 00:17:57 +05:30 committed by Nick Craig-Wood
parent efd826ad4b
commit 159f2e29a8
2 changed files with 8 additions and 4 deletions

View File

@ -26,9 +26,8 @@ func AddFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *httplib.Options)
flags.StringVarP(flagSet, &Opt.Realm, prefix+"realm", "", Opt.Realm, "realm for authentication") flags.StringVarP(flagSet, &Opt.Realm, prefix+"realm", "", Opt.Realm, "realm for authentication")
flags.StringVarP(flagSet, &Opt.BasicUser, prefix+"user", "", Opt.BasicUser, "User name for authentication.") flags.StringVarP(flagSet, &Opt.BasicUser, prefix+"user", "", Opt.BasicUser, "User name for authentication.")
flags.StringVarP(flagSet, &Opt.BasicPass, prefix+"pass", "", Opt.BasicPass, "Password for authentication.") flags.StringVarP(flagSet, &Opt.BasicPass, prefix+"pass", "", Opt.BasicPass, "Password for authentication.")
if prefix == "" { flags.StringVarP(flagSet, &Opt.Prefix, prefix+"prefix", "", Opt.Prefix, "Prefix for URLs.")
flags.StringVarP(flagSet, &Opt.Prefix, prefix+"prefix", "", Opt.Prefix, "Prefix for URLs.")
}
} }
// AddFlags adds flags for the httplib // AddFlags adds flags for the httplib

View File

@ -138,7 +138,11 @@ func writeError(path string, in rc.Params, w http.ResponseWriter, err error, sta
// handler reads incoming requests and dispatches them // handler reads incoming requests and dispatches them
func (s *Server) handler(w http.ResponseWriter, r *http.Request) { func (s *Server) handler(w http.ResponseWriter, r *http.Request) {
path := strings.TrimLeft(r.URL.Path, "/") urlPath, ok := s.Path(w, r)
if !ok {
return
}
path := strings.TrimLeft(urlPath, "/")
allowOrigin := rcflags.Opt.AccessControlAllowOrigin allowOrigin := rcflags.Opt.AccessControlAllowOrigin
if allowOrigin != "" { if allowOrigin != "" {
@ -311,6 +315,7 @@ func (s *Server) handleGet(w http.ResponseWriter, r *http.Request, path string)
return return
case s.files != nil: case s.files != nil:
// Serve the files // Serve the files
r.URL.Path = "/" + path
s.files.ServeHTTP(w, r) s.files.ServeHTTP(w, r)
return return
case path == "" && s.opt.Serve: case path == "" && s.opt.Serve: