Add http-namespace Flag (#9)

* add namespace config

* add namespace option

* add namespace flag

* update docs

* oops :D
This commit is contained in:
Alex Unger
2019-12-27 19:58:41 +01:00
committed by Jörn Friedrich Dreyer
parent 1b97549788
commit c5c77e2412
5 changed files with 27 additions and 8 deletions
+3
View File
@@ -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 `/`
+3 -2
View File
@@ -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.
+7
View File
@@ -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: "/",
+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
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
}
}
+1 -1
View File
@@ -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),