2024-01-28 07:20:59 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-02-16 13:39:55 +00:00
|
|
|
|
2024-01-28 07:20:59 +00:00
|
|
|
router2 "git.lumeweb.com/LumeWeb/portal/api/router"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type API interface {
|
|
|
|
Name() string
|
|
|
|
Init() error
|
|
|
|
Start(ctx context.Context) error
|
|
|
|
Stop(ctx context.Context) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type APIEntry struct {
|
2024-02-16 13:39:55 +00:00
|
|
|
Key string
|
|
|
|
Module fx.Option
|
2024-01-28 07:20:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var apiRegistry []APIEntry
|
2024-02-25 13:36:32 +00:00
|
|
|
var router *router2.APIRouter
|
2024-01-28 07:20:59 +00:00
|
|
|
|
2024-01-28 09:44:16 +00:00
|
|
|
func init() {
|
2024-02-25 13:36:32 +00:00
|
|
|
router = router2.NewAPIRouter()
|
2024-01-28 09:44:16 +00:00
|
|
|
}
|
|
|
|
|
2024-01-28 07:20:59 +00:00
|
|
|
func Register(entry APIEntry) {
|
|
|
|
apiRegistry = append(apiRegistry, entry)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetRegistry() []APIEntry {
|
|
|
|
return apiRegistry
|
|
|
|
}
|
|
|
|
|
2024-02-25 13:36:32 +00:00
|
|
|
func GetRouter() *router2.APIRouter {
|
2024-01-28 07:20:59 +00:00
|
|
|
return router
|
|
|
|
}
|