summaryrefslogtreecommitdiff
path: root/app/app.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-12 18:11:05 -0600
committermo khan <mo@mokhan.ca>2025-04-12 18:11:05 -0600
commit0bef608297d7def2a18d054e7230fe0e0a3710a7 (patch)
tree93a8ec34baa695705832ace22266e1f13cb9e64e /app/app.go
parent54715831a2d307390c05214b6ae8bc721ade6680 (diff)
refactor: extract mountable interface to allow controllers to mount themselves into the muxHEADmain
Diffstat (limited to 'app/app.go')
-rw-r--r--app/app.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/app.go b/app/app.go
new file mode 100644
index 0000000..3edd5f3
--- /dev/null
+++ b/app/app.go
@@ -0,0 +1,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
+}