From d87995c3629cac4671b05073915214f45d0c7112 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 17:49:32 +0530 Subject: refactor(api): centralize resource URLs --- internal/api/photos.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/api/photos.go') diff --git a/internal/api/photos.go b/internal/api/photos.go index 2d492b1..92c5c04 100644 --- a/internal/api/photos.go +++ b/internal/api/photos.go @@ -30,8 +30,8 @@ func (s *Server) handlePhotos( DateTaken: photo.DateTaken, Width: photo.Width, Height: photo.Height, - ThumbnailURL: "/thumb/" + photo.ID, - PhotoURL: "/photo/" + photo.ID, + ThumbnailURL: thumbnailURL(photo.ID), + PhotoURL: photoURL(photo.ID), }) } -- cgit v1.2.3 From f108043068c8818c616cc2e760f53839d4ba9b01 Mon Sep 17 00:00:00 2001 From: RanXom Date: Mon, 13 Jul 2026 17:53:46 +0530 Subject: refactor(api): return structured error responses --- internal/api/photos.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'internal/api/photos.go') diff --git a/internal/api/photos.go b/internal/api/photos.go index 92c5c04..ca6b038 100644 --- a/internal/api/photos.go +++ b/internal/api/photos.go @@ -12,12 +12,12 @@ func (s *Server) handlePhotos( ) { photos, err := s.gallery.Gallery(r.Context()) if err != nil { - log.Printf("gallery: %v", err) + log.Printf("build gallery: %v", err) - http.Error( + writeError( w, - http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError, + "failed to build gallery", ) return } @@ -38,10 +38,12 @@ func (s *Server) handlePhotos( w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(response); err != nil { - http.Error( + log.Printf("encode photos response: %v", err) + + writeError( w, - http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError, + "failed to encode response", ) } } -- cgit v1.2.3