From d87bcee585883f22b2ca0b42db67bf815cc7c1fc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 7 May 2026 00:20:15 +0300 Subject: Task 51: add API error helpers --- internal/api/handlers_share.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/api/handlers_share.go') diff --git a/internal/api/handlers_share.go b/internal/api/handlers_share.go index ed6ae20..54ce60b 100644 --- a/internal/api/handlers_share.go +++ b/internal/api/handlers_share.go @@ -22,7 +22,7 @@ func (s *Server) handleCreateShare(w http.ResponseWriter, r *http.Request) { } id := pathID(r, "id") if id == 0 { - writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid media id"}) + badRequest(w, "invalid media id") return } expiresAt := time.Now().Add(time.Duration(s.cfg.ShareDefaultExpiryDays) * 24 * time.Hour) @@ -40,7 +40,7 @@ func (s *Server) handleListShares(w http.ResponseWriter, r *http.Request) { } id := pathID(r, "id") if id == 0 { - writeJSON(w, http.StatusBadRequest, map[string]string{"error": "invalid media id"}) + badRequest(w, "invalid media id") return } shares, err := s.shareSvc.ListShares(r.Context(), id, userIDFromContext(r)) @@ -57,7 +57,7 @@ func (s *Server) handleRevokeShare(w http.ResponseWriter, r *http.Request) { } token := r.PathValue("token") if token == "" { - writeJSON(w, http.StatusBadRequest, map[string]string{"error": "token required"}) + badRequest(w, "token required") return } if err := s.shareSvc.RevokeShare(r.Context(), token, userIDFromContext(r)); err != nil { -- cgit v1.2.3