From d6a80470f27b6acf6273410cea88b32555fa4973 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 18 Dec 2019 12:51:09 +0100 Subject: [PATCH] added namespace option --- pkg/server/http/option.go | 18 +++++++++++++----- pkg/server/http/server.go | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/server/http/option.go b/pkg/server/http/option.go index 185f1b598..67c405763 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 8305fc431..c8f89645a 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.Namespace), http.Name("phoenix"), http.Version(version.String), http.Address(options.Config.HTTP.Addr),