aboutsummaryrefslogtreecommitdiff
path: root/internal/service/photo.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/service/photo.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/service/photo.go')
-rw-r--r--internal/service/photo.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/service/photo.go b/internal/service/photo.go
new file mode 100644
index 0000000..018ba6b
--- /dev/null
+++ b/internal/service/photo.go
@@ -0,0 +1,29 @@
+package service
+
+import (
+ "context"
+ "errors"
+
+ "github.com/RanXom/galleryd/internal/gallery"
+)
+
+var ErrPhotoNotFound = errors.New("photo not found")
+
+// Photo returns a single photo by its ID.
+func (s *galleryService) Photo(
+ ctx context.Context,
+ id string,
+) (gallery.Photo, error) {
+ select {
+ case <-ctx.Done():
+ return gallery.Photo{}, ctx.Err()
+ default:
+ }
+
+ photo, ok := s.index.byID[id]
+ if !ok {
+ return gallery.Photo{}, ErrPhotoNotFound
+ }
+
+ return photo, nil
+}