refactor(server/api): migrate auth/me handlers to writeErr(err) (T3a)

This commit is contained in:
2026-05-07 20:25:26 -04:00
parent 58766dbebe
commit e382b0d718
9 changed files with 66 additions and 56 deletions
+4 -3
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"net/http"
"git.fabledsword.com/bvandeusen/minstrel/internal/apierror"
"git.fabledsword.com/bvandeusen/minstrel/internal/auth"
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
)
@@ -16,13 +17,13 @@ import (
func (h *handlers) handleGetMyHistory(w http.ResponseWriter, r *http.Request) {
user, ok := auth.UserFromContext(r.Context())
if !ok {
writeErr(w, http.StatusUnauthorized, "unauthorized", "authentication required")
writeErr(w, apierror.ErrUnauthorized)
return
}
limit, offset, perr := parsePaging(r.URL.Query())
if perr != nil {
writeErr(w, http.StatusBadRequest, "bad_paging", "invalid limit or offset")
writeErr(w, apierror.BadRequest("bad_paging", "invalid limit or offset"))
return
}
@@ -33,7 +34,7 @@ func (h *handlers) handleGetMyHistory(w http.ResponseWriter, r *http.Request) {
})
if err != nil {
h.logger.Error("api: list user history", "err", err)
writeErr(w, http.StatusInternalServerError, "server_error", "failed to load history")
writeErr(w, apierror.InternalMsg("failed to load history", err))
return
}