blob: 018ba6b8c41166b3e45a4df1ede52f0b94de07c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
}
|