mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-24 02:56:52 -05:00
auth-api: deal with errors properly in NewService
This commit is contained in:
@@ -32,7 +32,7 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
return http.Service{}, fmt.Errorf("could not initialize http service: %w", err)
|
||||
}
|
||||
|
||||
handle := svc.NewService(
|
||||
handle, err := svc.NewService(
|
||||
svc.Logger(options.Logger),
|
||||
svc.Config(options.Config),
|
||||
svc.Metrics(options.Metrics),
|
||||
@@ -47,6 +47,9 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
opencloudmiddleware.Logger(options.Logger),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return http.Service{}, err
|
||||
}
|
||||
|
||||
{
|
||||
handle = svc.NewInstrument(handle, options.Metrics)
|
||||
|
||||
@@ -29,7 +29,7 @@ type Service interface {
|
||||
}
|
||||
|
||||
// NewService returns a service implementation for Service.
|
||||
func NewService(opts ...Option) Service {
|
||||
func NewService(opts ...Option) (Service, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
m := chi.NewMux()
|
||||
@@ -47,7 +47,7 @@ func NewService(opts ...Option) Service {
|
||||
|
||||
svc, err := NewAuthenticationApi(options.Config, &options.Logger, options.Metrics, options.TraceProvider, m)
|
||||
if err != nil {
|
||||
panic(err) // TODO p.bleser what to do when we encounter an error in a NewService() ?
|
||||
return nil, err
|
||||
}
|
||||
|
||||
m.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
@@ -59,7 +59,7 @@ func NewService(opts ...Option) Service {
|
||||
return nil
|
||||
})
|
||||
|
||||
return svc
|
||||
return svc, nil
|
||||
}
|
||||
|
||||
type AuthenticationApi struct {
|
||||
|
||||
Reference in New Issue
Block a user