summaryrefslogtreecommitdiff
path: root/app/init.go
blob: 9ff7bec7fa54cb98f72e2b4539badbc6d8384714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package app

import (
	"net/http"

	"github.com/xlgmokha/x/pkg/ioc"
	"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/health"
	"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/controllers/sparkles"
	"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/db"
)

func init() {
	ioc.RegisterSingleton[db.Repository](ioc.Default, func() db.Repository {
		return db.NewRepository()
	})
	ioc.RegisterSingleton[*http.ServeMux](ioc.Default, func() *http.ServeMux {
		return http.NewServeMux()
	})
	ioc.Register[*sparkles.Controller](ioc.Default, func() *sparkles.Controller {
		return sparkles.New(ioc.MustResolve[db.Repository](ioc.Default))
	})
	ioc.Register[*health.Controller](ioc.Default, func() *health.Controller {
		return health.New()
	})
}