package app import ( "context" "github.com/pkg/errors" "gitlab.com/wpetit/goweb/logger" ) type Options struct { ModuleFactories []ServerModuleFactory ErrorHandler func(ctx context.Context, err error) } type OptionFunc func(opts *Options) func NewOptions(funcs ...OptionFunc) *Options { opts := &Options{ ModuleFactories: make([]ServerModuleFactory, 0), ErrorHandler: func(ctx context.Context, err error) { logger.Error(ctx, err.Error(), logger.E(errors.WithStack(err))) }, } for _, fn := range funcs { fn(opts) } return opts } func WithModulesFactories(factories ...ServerModuleFactory) OptionFunc { return func(opts *Options) { opts.ModuleFactories = factories } }