diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index 4282ad17b..d1cf13078 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -129,6 +129,9 @@ If you prefer to configure the service with commandline flags you can see the av --http-addr : Address to bind http server, defaults to `0.0.0.0:9115` +--http-namespace +: Namespace for internal services communication, defaults to `com.owncloud.web` + --http-root : Root path of http server, defaults to `/` diff --git a/pkg/config/config.go b/pkg/config/config.go index 8067a011d..c92c9820c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -17,8 +17,9 @@ type Debug struct { // HTTP defines the available http configuration. type HTTP struct { - Addr string - Root string + Addr string + Namespace string + Root string } // Tracing defines the available tracing configuration. diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index a414d238a..35f873ad8 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -120,6 +120,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVar: "WEBDAV_HTTP_ADDR", Destination: &cfg.HTTP.Addr, }, + &cli.StringFlag{ + Name: "http-namespace", + Value: "com.owncloud.web", + Usage: "Set the base namespace for service discovery", + EnvVar: "WEBDAV_HTTP_NAMESPACE", + Destination: &cfg.HTTP.Namespace, + }, &cli.StringFlag{ Name: "http-root", Value: "/", diff --git a/pkg/server/http/option.go b/pkg/server/http/option.go index a56fef4d5..42eefc668 100644 --- a/pkg/server/http/option.go +++ b/pkg/server/http/option.go @@ -14,11 +14,12 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Logger log.Logger - Context context.Context - Config *config.Config - Metrics *metrics.Metrics - Flags []cli.Flag + Namespace string + Logger log.Logger + Context context.Context + Config *config.Config + Metrics *metrics.Metrics + Flags []cli.Flag } // newOptions initializes the available default options. @@ -66,3 +67,10 @@ func Flags(val []cli.Flag) Option { o.Flags = append(o.Flags, val...) } } + +// Namespace provides a function to set the namespace option. +func Namespace(val string) Option { + return func(o *Options) { + o.Namespace = val + } +} diff --git a/pkg/server/http/server.go b/pkg/server/http/server.go index 93d3c1038..93c5ff66a 100644 --- a/pkg/server/http/server.go +++ b/pkg/server/http/server.go @@ -13,7 +13,7 @@ func Server(opts ...Option) (http.Service, error) { service := http.NewService( http.Logger(options.Logger), - http.Namespace("go.micro.web"), + http.Namespace(options.Config.HTTP.Namespace), http.Name("webdav"), http.Version(version.String), http.Address(options.Config.HTTP.Addr),