diff --git a/pkg/command/server.go b/pkg/command/server.go index be5b7f0201..8b47339a6f 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -38,6 +38,7 @@ func Server(cfg *config.Config) cli.Command { }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) + httpNamespace := c.String("http-namespace") if cfg.Tracing.Enabled { switch t := cfg.Tracing.Type; t { @@ -135,6 +136,7 @@ func Server(cfg *config.Config) cli.Command { server, err := http.Server( http.Logger(logger), http.Context(ctx), + http.Namespace(httpNamespace), http.Config(cfg), http.Metrics(metrics), http.Flags(flagset.RootWithConfig(cfg)), diff --git a/pkg/config/config.go b/pkg/config/config.go index 6725438616..0f330f7eec 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,7 +37,8 @@ type Asset struct { // Phoenix defines the available phoenic configuration. type Phoenix struct { - Path string + Path string + Namespace string } // Config combines all available configuration parts. diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index 48a68a9979..9c1567dc68 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -141,5 +141,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVar: "PHOENIX_WEB_CONFIG", Destination: &cfg.Phoenix.Path, }, + &cli.StringFlag{ + Name: "http-namespace", + Value: "com.owncloud", + Usage: "Set the base namespace for the http namespace", + EnvVar: "PHOENIX_NAMESPACE", + Destination: &cfg.Phoenix.Namespace, + }, } } diff --git a/pkg/server/http/option.go b/pkg/server/http/option.go index 185f1b598d..67c4057637 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 + Logger log.Logger + Context context.Context + Config *config.Config + Metrics *metrics.Metrics + Flags []cli.Flag + Namespace string } // 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 8305fc431e..65e50f7c7d 100644 --- a/pkg/server/http/server.go +++ b/pkg/server/http/server.go @@ -13,8 +13,8 @@ func Server(opts ...Option) (http.Service, error) { service := http.NewService( http.Logger(options.Logger), - http.Namespace("go.micro.web"), - http.Name("phoenix"), + http.Namespace(options.Namespace), + http.Name("web.phoenix"), http.Version(version.String), http.Address(options.Config.HTTP.Addr), http.Context(options.Context),