diff --git a/onlyoffice/pkg/command/server.go b/onlyoffice/pkg/command/server.go index 815e3eecf..90218bdd0 100644 --- a/onlyoffice/pkg/command/server.go +++ b/onlyoffice/pkg/command/server.go @@ -40,7 +40,6 @@ 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 { @@ -136,8 +135,8 @@ func Server(cfg *config.Config) *cli.Command { { server, err := http.Server( + http.Name("onlyoffice"), http.Logger(logger), - http.Namespace(httpNamespace), http.Context(ctx), http.Config(cfg), http.Metrics(metrics), diff --git a/onlyoffice/pkg/server/http/option.go b/onlyoffice/pkg/server/http/option.go index df71b2b1e..25deeb1e2 100644 --- a/onlyoffice/pkg/server/http/option.go +++ b/onlyoffice/pkg/server/http/option.go @@ -14,12 +14,12 @@ type Option func(o *Options) // Options defines the available options for this package. type Options struct { - Namespace string - Logger log.Logger - Context context.Context - Config *config.Config - Metrics *metrics.Metrics - Flags []cli.Flag + Name string + Logger log.Logger + Context context.Context + Config *config.Config + Metrics *metrics.Metrics + Flags []cli.Flag } // newOptions initializes the available default options. @@ -68,9 +68,9 @@ func Flags(val []cli.Flag) Option { } } -// Namespace provides a function to set the Namespace option. -func Namespace(val string) Option { +// Name provides a function to set the Name option. +func Name(val string) Option { return func(o *Options) { - o.Namespace = val + o.Name = val } } diff --git a/onlyoffice/pkg/server/http/server.go b/onlyoffice/pkg/server/http/server.go index 0cc7d1d14..4c4fb6e4e 100644 --- a/onlyoffice/pkg/server/http/server.go +++ b/onlyoffice/pkg/server/http/server.go @@ -1,7 +1,6 @@ package http import ( - "github.com/go-chi/chi" "github.com/owncloud/ocis-pkg/v2/middleware" "github.com/owncloud/ocis-pkg/v2/service/http" "github.com/owncloud/ocis/onlyoffice/pkg/assets" @@ -14,8 +13,8 @@ func Server(opts ...Option) (http.Service, error) { options := newOptions(opts...) service := http.NewService( + http.Name(options.Name), http.Logger(options.Logger), - http.Name("onlyoffice"), http.Version(version.String), http.Namespace(options.Config.HTTP.Namespace), http.Address(options.Config.HTTP.Addr), @@ -33,12 +32,19 @@ func Server(opts ...Option) (http.Service, error) { middleware.Cors, middleware.Secure, middleware.Version( - "onlyoffice", + options.Name, version.String, ), middleware.Logger( options.Logger, ), + middleware.Static( + options.Config.HTTP.Root, + assets.New( + assets.Logger(options.Logger), + assets.Config(options.Config), + ), + ), ), ) @@ -48,21 +54,9 @@ func Server(opts ...Option) (http.Service, error) { handle = svc.NewTracing(handle) } - mux := chi.NewMux() - - mux.Use(middleware.Static( - options.Config.HTTP.Root, - assets.New( - assets.Logger(options.Logger), - assets.Config(options.Config), - ), - )) - - mux.Route(options.Config.HTTP.Root, func(r chi.Router) {}) - service.Handle( "/", - mux, + handle, ) service.Init() diff --git a/onlyoffice/pkg/service/v0/service.go b/onlyoffice/pkg/service/v0/service.go index 65f9264fe..09b28c71b 100644 --- a/onlyoffice/pkg/service/v0/service.go +++ b/onlyoffice/pkg/service/v0/service.go @@ -24,6 +24,8 @@ func NewService(opts ...Option) Service { mux: m, } + m.Route(options.Config.HTTP.Root, func(r chi.Router) {}) + return svc }