Move service handler init to the server command
We kept two instances of the service handler in parallel
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
mclient "github.com/micro/go-micro/v2/client"
|
||||
"github.com/owncloud/ocis-accounts/pkg/assets"
|
||||
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis-accounts/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-accounts/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/account"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/roles"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/http"
|
||||
settings "github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Server initializes the http service and server.
|
||||
func Server(opts ...Option) http.Service {
|
||||
options := newOptions(opts...)
|
||||
handler := options.Handler
|
||||
|
||||
service := http.NewService(
|
||||
http.Logger(options.Logger),
|
||||
@@ -30,25 +25,6 @@ func Server(opts ...Option) http.Service {
|
||||
http.Flags(options.Flags...),
|
||||
)
|
||||
|
||||
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
|
||||
// https://github.com/owncloud/ocis-proxy/issues/38
|
||||
rs := settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient)
|
||||
roleManager := roles.NewManager(
|
||||
roles.CacheSize(1024),
|
||||
roles.CacheTTL(time.Hour*24*7),
|
||||
roles.Logger(options.Logger),
|
||||
roles.RoleService(rs),
|
||||
)
|
||||
handler, err := svc.New(
|
||||
svc.Logger(options.Logger),
|
||||
svc.Config(options.Config),
|
||||
svc.RoleManager(&roleManager),
|
||||
svc.RoleService(rs),
|
||||
)
|
||||
if err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not initialize service handler")
|
||||
}
|
||||
|
||||
mux := chi.NewMux()
|
||||
|
||||
mux.Use(middleware.RealIP)
|
||||
|
||||
Reference in New Issue
Block a user