refactor: use a centralized list key for enabled protocols
This commit is contained in:
parent
f7057142eb
commit
8c89796341
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/registry"
|
||||
"git.lumeweb.com/LumeWeb/portal/api/router"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
@ -28,8 +29,9 @@ func getModulesBasedOnConfig() []fx.Option {
|
|||
|
||||
func BuildApis(config *viper.Viper) fx.Option {
|
||||
var options []fx.Option
|
||||
enabledProtocols := config.GetStringSlice("core.protocols")
|
||||
for _, entry := range registry.GetRegistry() {
|
||||
if config.GetBool("protocols." + entry.Key + ".enabled") {
|
||||
if lo.Contains(enabledProtocols, entry.Key) {
|
||||
options = append(options, entry.Module)
|
||||
if entry.InitFunc != nil {
|
||||
options = append(options, fx.Invoke(entry.InitFunc))
|
||||
|
|
|
@ -3,6 +3,7 @@ package protocols
|
|||
import (
|
||||
"context"
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols/registry"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
@ -17,8 +18,9 @@ func RegisterProtocols() {
|
|||
|
||||
func BuildProtocols(config *viper.Viper) fx.Option {
|
||||
var options []fx.Option
|
||||
enabledProtocols := config.GetStringSlice("core.protocols")
|
||||
for _, entry := range registry.GetRegistry() {
|
||||
if config.GetBool("protocols." + entry.Key + ".enabled") {
|
||||
if lo.Contains(enabledProtocols, entry.Key) {
|
||||
options = append(options, entry.Module)
|
||||
if entry.InitFunc != nil {
|
||||
options = append(options, fx.Invoke(entry.InitFunc))
|
||||
|
|
Loading…
Reference in New Issue