summaryrefslogtreecommitdiff
path: root/app/controllers/sparkles
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/sparkles')
-rw-r--r--app/controllers/sparkles/controller.go9
-rw-r--r--app/controllers/sparkles/init.go4
2 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/sparkles/controller.go b/app/controllers/sparkles/controller.go
index dbb5f55..4963950 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/app/domain"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/middleware"
+ "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
)
type Controller struct {
@@ -31,7 +32,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 {
- log.WithFields(r.Context(), log.Fields{"error": err})
+ pls.LogError(r.Context(), err)
w.WriteHeader(http.StatusInternalServerError)
}
}
@@ -45,14 +46,14 @@ func (c *Controller) Create(w http.ResponseWriter, r *http.Request) {
}
if err := c.db.Save(sparkle); err != nil {
- log.WithFields(r.Context(), log.Fields{"error": err})
+ pls.LogError(r.Context(), err)
w.WriteHeader(http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusCreated)
if err := serde.ToHTTP(w, r, sparkle); err != nil {
- log.WithFields(r.Context(), log.Fields{"error": err})
+ pls.LogError(r.Context(), err)
w.WriteHeader(http.StatusInternalServerError)
return
}
@@ -66,7 +67,7 @@ func (c *Controller) Restore(w http.ResponseWriter, r *http.Request) {
x.Each(sparkles, func(sparkle *domain.Sparkle) {
if err := c.db.Save(sparkle); err != nil {
- log.WithFields(r.Context(), log.Fields{"error": err})
+ pls.LogError(r.Context(), err)
}
})
}
diff --git a/app/controllers/sparkles/init.go b/app/controllers/sparkles/init.go
index 1118a09..c85a49d 100644
--- a/app/controllers/sparkles/init.go
+++ b/app/controllers/sparkles/init.go
@@ -3,18 +3,18 @@ package sparkles
import (
"net/http"
- "github.com/xlgmokha/x/pkg/log"
"github.com/xlgmokha/x/pkg/mapper"
"github.com/xlgmokha/x/pkg/serde"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/cfg"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
+ "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
)
func init() {
mapper.Register[*http.Request, *domain.Sparkle](func(r *http.Request) *domain.Sparkle {
sparkle, err := serde.FromHTTP[*domain.Sparkle](r)
if err != nil {
- log.WithFields(r.Context(), log.Fields{"error": err})
+ pls.LogError(r.Context(), err)
}
sparkle.Author = cfg.CurrentUser.From(r.Context())
return sparkle