diff options
Diffstat (limited to 'app/controllers/sparkles/controller.go')
| -rw-r--r-- | app/controllers/sparkles/controller.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go index 07a21ba..04eee12 100644 --- a/app/controllers/sparkles/controller.go +++ b/app/controllers/sparkles/controller.go @@ -9,6 +9,7 @@ import ( "github.com/xlgmokha/x/pkg/x" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/db" "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/domain" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/web/middleware" ) type Controller struct { @@ -20,8 +21,10 @@ func New(db db.Repository[*domain.Sparkle]) *Controller { } func (c *Controller) MountTo(mux *http.ServeMux) { + requireUser := middleware.RequireUser(http.StatusFound, "/") + mux.HandleFunc("GET /sparkles", c.Index) - mux.HandleFunc("POST /sparkles", c.Create) + mux.Handle("POST /sparkles", requireUser(http.HandlerFunc(c.Create))) } func (c *Controller) Index(w http.ResponseWriter, r *http.Request) { |
