From 0bef608297d7def2a18d054e7230fe0e0a3710a7 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 12 Apr 2025 18:11:05 -0600 Subject: refactor: extract mountable interface to allow controllers to mount themselves into the mux --- app/controllers/sparkles/controller.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/controllers/sparkles/controller.go') diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go index 365184f..f00f40c 100644 --- a/app/controllers/sparkles/controller.go +++ b/app/controllers/sparkles/controller.go @@ -16,6 +16,11 @@ func New(db db.Repository) *Controller { return &Controller{db: db} } +func (c *Controller) MountTo(mux *http.ServeMux) { + mux.HandleFunc("GET /sparkles", c.Index) + mux.HandleFunc("POST /sparkles", c.Create) +} + func (c *Controller) Index(w http.ResponseWriter, r *http.Request) { serde.ToHTTP(w, r, c.db.All()) } -- cgit v1.2.3