Add Namespace flag (#21)

* added http-namespace to the flagset

* update description

* added namespace option to the options list

* added namespace as a config parameter

* updated docs

* fix default value override
This commit is contained in:
Alex Unger
2019-12-27 13:09:27 +01:00
committed by Jörn Friedrich Dreyer
parent a0ebc35b80
commit 91e17d0cde
5 changed files with 27 additions and 8 deletions
+13 -5
View File
@@ -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
}
}
+1 -1
View File
@@ -14,7 +14,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("graph"),
http.Version(version.String),
http.Address(options.Config.HTTP.Addr),