From 23327d0ce3e641afd1316a112e1c7f9b443abe13 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 24 May 2025 00:16:14 -0600 Subject: refactor: decorate handler with access check middleware --- app/controllers/dashboard/controller.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'app/controllers/dashboard/controller.go') diff --git a/app/controllers/dashboard/controller.go b/app/controllers/dashboard/controller.go index 097834f..04a7ed1 100644 --- a/app/controllers/dashboard/controller.go +++ b/app/controllers/dashboard/controller.go @@ -3,6 +3,7 @@ package dashboard import ( "net/http" + "github.com/xlgmokha/x/pkg/x" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/middleware" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/views" @@ -17,9 +18,11 @@ func New() *Controller { } func (c *Controller) MountTo(mux *http.ServeMux) { - requireUser := middleware.RequireUser() + mux.Handle("GET /dashboard", x.Middleware[http.Handler]( + http.HandlerFunc(c.Show), + middleware.RequireUser(), + )) - mux.Handle("GET /dashboard", requireUser(http.HandlerFunc(c.Show))) mux.Handle("GET /dashboard/nav", http.HandlerFunc(c.Navigation)) } -- cgit v1.2.3