diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-07 10:47:31 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-07 10:47:31 -0700 |
| commit | c82468b1b32ad5bfb347fe65cd5dcfb6680795d1 (patch) | |
| tree | 679b4728fdae2ed296730a49f5100ddcf3c25f98 /app/controllers/sparkles/controller.go | |
| parent | f0fbdab72254d68d0a3a4a49a4a1646f89f0f913 (diff) | |
refactor: provide context to repository to apply timeout
Diffstat (limited to 'app/controllers/sparkles/controller.go')
| -rw-r--r-- | app/controllers/sparkles/controller.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go index 4963950..cd86cd2 100644 --- a/app/controllers/sparkles/controller.go +++ b/app/controllers/sparkles/controller.go @@ -31,7 +31,7 @@ func (c *Controller) MountTo(mux *http.ServeMux) { } func (c *Controller) Index(w http.ResponseWriter, r *http.Request) { - if err := serde.ToHTTP(w, r, c.db.All()); err != nil { + if err := serde.ToHTTP(w, r, c.db.All(r.Context())); err != nil { pls.LogError(r.Context(), err) w.WriteHeader(http.StatusInternalServerError) } @@ -45,7 +45,7 @@ func (c *Controller) Create(w http.ResponseWriter, r *http.Request) { return } - if err := c.db.Save(sparkle); err != nil { + if err := c.db.Save(r.Context(), sparkle); err != nil { pls.LogError(r.Context(), err) w.WriteHeader(http.StatusBadRequest) return @@ -66,7 +66,7 @@ func (c *Controller) Restore(w http.ResponseWriter, r *http.Request) { log.WithFields(r.Context(), log.Fields{"sparkles": sparkles}) x.Each(sparkles, func(sparkle *domain.Sparkle) { - if err := c.db.Save(sparkle); err != nil { + if err := c.db.Save(r.Context(), sparkle); err != nil { pls.LogError(r.Context(), err) } }) |
