aboutsummaryrefslogtreecommitdiff
path: root/internal/api/photos.go
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-07-13 19:45:40 +0530
committerGitHub <noreply@github.com>2026-07-13 19:45:40 +0530
commit5d4eaf85434658f6fed621016e0bc2bae59e88d1 (patch)
tree93ec34c177b6a48d90d5024313c3a10f5b7c5d2b /internal/api/photos.go
parentf41b0b92046e1bee512b3e4143ed9dc9a9ba9713 (diff)
parent8e8f0bd38f0cc0ee435ae2ed392a206e1ea73a32 (diff)
downloadgalleryd-5d4eaf85434658f6fed621016e0bc2bae59e88d1.tar.xz
galleryd-5d4eaf85434658f6fed621016e0bc2bae59e88d1.zip
Merge pull request #8 from RanXom/feat/api
Feat/api: expose gallery HTTP API
Diffstat (limited to 'internal/api/photos.go')
-rw-r--r--internal/api/photos.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/api/photos.go b/internal/api/photos.go
index 2d492b1..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
}
@@ -30,18 +30,20 @@ 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),
})
}
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",
)
}
}