From 2854b695a0df016ef1a9c67303c15911b0ed4b72 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 21 Apr 2025 12:00:16 -0600 Subject: refactor: provide the root dir as a parameter --- app/app.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/app.go') diff --git a/app/app.go b/app/app.go index 51979a4..8ccb71b 100644 --- a/app/app.go +++ b/app/app.go @@ -2,6 +2,7 @@ package app import ( "net/http" + "path/filepath" "github.com/rs/zerolog" "github.com/xlgmokha/x/pkg/ioc" @@ -15,7 +16,7 @@ import ( "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/middleware" ) -func New() http.Handler { +func New(rootDir string) http.Handler { mux := ioc.MustResolve[*http.ServeMux](ioc.Default) mountable := []web.Mountable{ @@ -28,7 +29,8 @@ func New() http.Handler { m.MountTo(mux) } - mux.Handle("GET /", http.FileServer(http.Dir("public"))) + dir := http.Dir(filepath.Join(rootDir, "public")) + mux.Handle("GET /", http.FileServer(dir)) logger := ioc.MustResolve[*zerolog.Logger](ioc.Default) oidc := ioc.MustResolve[*oidc.OpenID](ioc.Default) -- cgit v1.2.3