summaryrefslogtreecommitdiff
path: root/internal/api/handlers_share.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-07 00:20:15 +0300
committerPaul Buetow <paul@buetow.org>2026-05-07 00:20:15 +0300
commitd87bcee585883f22b2ca0b42db67bf815cc7c1fc (patch)
treea879c345d3ebaecf526f12d7ad6cf97c6f7f4dba /internal/api/handlers_share.go
parente1bea8d74391a20201327299481550bf94766236 (diff)
Task 51: add API error helpers
Diffstat (limited to 'internal/api/handlers_share.go')
-rw-r--r--internal/api/handlers_share.go6
1 files changed, 3 insertions, 3 deletions
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 {