Files
opencloud/pkg/server/grpc/server.go
Benedikt Kulmann 3f04adf4ff Set up http server
- set up http server for a) handling the service requests and b)
serving the static assets for the ocis-web extension
- align the server command with other ocis-extensions, including config
variable naming
2020-07-01 11:05:32 +02:00

35 lines
988 B
Go

package grpc
import (
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
svc "github.com/owncloud/ocis-accounts/pkg/service/v0"
"github.com/owncloud/ocis-pkg/v2/service/grpc"
)
// Server initializes a new go-micro service ready to run
func Server(opts ...Option) grpc.Service {
options := newOptions(opts...)
service := grpc.NewService(
grpc.Name(options.Config.Server.Name),
grpc.Context(options.Context),
grpc.Address(options.Config.GRPC.Addr),
grpc.Namespace(options.Config.GRPC.Namespace),
grpc.Logger(options.Logger),
grpc.Flags(options.Flags...),
)
var hdlr *svc.Service
var err error
if hdlr, err = svc.New(svc.Logger(options.Logger), svc.Config(options.Config)); err != nil {
options.Logger.Fatal().Err(err).Msg("could not initialize service handler")
}
if err = proto.RegisterAccountsServiceHandler(service.Server(), hdlr); err != nil {
options.Logger.Fatal().Err(err).Msg("could not register service handler")
}
service.Init()
return service
}