migrate webdav to the new config scheme

This commit is contained in:
A.Unger
2021-11-05 13:45:15 +01:00
parent ca997e5bfc
commit ad72f7574c
7 changed files with 270 additions and 131 deletions
+4 -12
View File
@@ -22,23 +22,15 @@ func Server(cfg *config.Config) *cli.Command {
Usage: "Start integrated server",
Flags: flagset.ServerWithConfig(cfg),
Before: func(ctx *cli.Context) error {
logger := NewLogger(cfg)
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
if !cfg.Supervised {
return ParseConfig(ctx, cfg)
}
if origins := ctx.StringSlice("cors-allowed-origins"); len(origins) != 0 {
cfg.HTTP.CORS.AllowedOrigins = origins
}
if methods := ctx.StringSlice("cors-allowed-methods"); len(methods) != 0 {
cfg.HTTP.CORS.AllowedMethods = methods
}
if headers := ctx.StringSlice("cors-allowed-headers"); len(headers) != 0 {
cfg.HTTP.CORS.AllowedOrigins = headers
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
logger := NewLogger(cfg)
logger.Debug().Str("service", "webdav").Msg("ignoring config file parsing when running supervised")
return nil
},