summaryrefslogtreecommitdiff
path: root/app/controllers/sparkles/controller.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-25 10:16:54 -0600
committermo khan <mo@mokhan.ca>2025-04-25 10:16:54 -0600
commit2cd89b747c7c255df9197132fcdf04d0c8cd2ff3 (patch)
tree53e8dffe9dd73f4471f073bcd0199dc9361fad70 /app/controllers/sparkles/controller.go
parent00b0381dfccab2ddff7de04933fdb11b32695faf (diff)
feat: record the author of the new sparkle
Diffstat (limited to 'app/controllers/sparkles/controller.go')
-rw-r--r--app/controllers/sparkles/controller.go5
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) {