summaryrefslogtreecommitdiff
path: root/app/app.go
blob: 3edd5f391cb680a6a04133b1c7d9e4802b926765 (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
26
27
package app

import (
	"net/http"

	"github.com/xlgmokha/x/pkg/ioc"
	"gitlab.com/mokhax/sparkled/app/controllers/health"
	"gitlab.com/mokhax/sparkled/app/controllers/sparkles"
	"gitlab.com/mokhax/sparkled/pkg/db"
	"gitlab.com/mokhax/sparkled/pkg/web"
)

func New() http.Handler {
	mux := ioc.MustResolve[*http.ServeMux](ioc.Default)

	mountable := []web.Mountable{
		sparkles.New(ioc.MustResolve[db.Repository](ioc.Default)),
		health.New(),
	}
	for _, m := range mountable {
		m.MountTo(mux)
	}

	mux.Handle("GET /", http.FileServer(http.Dir("public")))

	return mux
}