mirror of
https://github.com/hacdias/webdav.git
synced 2024-04-21 12:32:06 +00:00
feat: add URL prefix(subpath) support (#31)
To adapt to situations such as working behind a reverse proxy dispatching query to different services by URL path prefix
This commit is contained in:
@@ -20,6 +20,7 @@ auth: true
|
||||
tls: false
|
||||
cert: cert.pem
|
||||
key: key.pem
|
||||
prefix: /
|
||||
|
||||
# Default user settings (will be merged)
|
||||
scope: .
|
||||
|
||||
@@ -114,6 +114,7 @@ func parseUsers(raw []interface{}, c *webdav.Config) {
|
||||
}
|
||||
|
||||
user.Handler = &wd.Handler{
|
||||
Prefix: c.User.Handler.Prefix,
|
||||
FileSystem: wd.Dir(user.Scope),
|
||||
LockSystem: wd.NewMemLS(),
|
||||
}
|
||||
@@ -170,6 +171,7 @@ func readConfig(flags *pflag.FlagSet) *webdav.Config {
|
||||
Modify: getOptB(flags, "modify"),
|
||||
Rules: []*webdav.Rule{},
|
||||
Handler: &wd.Handler{
|
||||
Prefix: getOpt(flags, "prefix"),
|
||||
FileSystem: wd.Dir(getOpt(flags, "scope")),
|
||||
LockSystem: wd.NewMemLS(),
|
||||
},
|
||||
|
||||
@@ -26,6 +26,7 @@ func init() {
|
||||
flags.String("key", "key.pem", "TLS key")
|
||||
flags.StringP("address", "a", "0.0.0.0", "address to listen to")
|
||||
flags.StringP("port", "p", "0", "port to listen to")
|
||||
flags.StringP("prefix", "P", "/", "URL path prefix")
|
||||
}
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
|
||||
Reference in New Issue
Block a user