summaryrefslogtreecommitdiff
path: root/player-server/internal/api/handlers_file.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-20 14:18:26 +0300
committerPaul Buetow <paul@buetow.org>2026-05-20 14:18:26 +0300
commit30e95cd41fc26cc2cbef658c47c690eb5e388b04 (patch)
tree6750d3fa31670c6b3c1f2efade0e1348de4ef2d5 /player-server/internal/api/handlers_file.go
parent0e5cefc30a4f6bc9d47069d6a3844027afc8bc55 (diff)
Extract app wiring from main.go into internal/app package (9a)
Move all dependency wiring, background worker startup, server lifecycle (Wire, StartBackgroundWorkers, RunServer, RunWithSignal, BuildLogger) into internal/app so cmd/player/main.go becomes thin: parse flags, load config, delegate to app.RunWithSignal. Updated main_test.go to call app.Wire and app.StartBackgroundWorkers directly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'player-server/internal/api/handlers_file.go')
-rw-r--r--player-server/internal/api/handlers_file.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/player-server/internal/api/handlers_file.go b/player-server/internal/api/handlers_file.go
index 97de92e..f1e8343 100644
--- a/player-server/internal/api/handlers_file.go
+++ b/player-server/internal/api/handlers_file.go
@@ -41,14 +41,14 @@ func (s *Server) fileHandler(fn func(context.Context, int64, int64) (*service.Fi
}
func (s *Server) handleStream(w http.ResponseWriter, r *http.Request) {
- if !requireService(w, s.browseSvc) {
+ if !requireService(w, s.media.Browse) {
return
}
- s.fileHandler(s.browseSvc.StreamMedia)(w, r)
+ s.fileHandler(s.media.Browse.StreamMedia)(w, r)
}
func (s *Server) handleDownload(w http.ResponseWriter, r *http.Request) {
- if !requireService(w, s.browseSvc) {
+ if !requireService(w, s.media.Browse) {
return
}
id, err := pathID(r, "id")
@@ -56,7 +56,7 @@ func (s *Server) handleDownload(w http.ResponseWriter, r *http.Request) {
badRequest(w, "invalid media id")
return
}
- res, err := s.browseSvc.DownloadMedia(r.Context(), id, userIDFromContext(r))
+ res, err := s.media.Browse.DownloadMedia(r.Context(), id, userIDFromContext(r))
if err != nil {
if errors.Is(err, service.ErrNotFound) {
notFound(w)
@@ -77,15 +77,15 @@ func (s *Server) handleDownload(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) handleThumbnail(w http.ResponseWriter, r *http.Request) {
- if !requireService(w, s.browseSvc) {
+ if !requireService(w, s.media.Browse) {
return
}
w.Header().Set("Cache-Control", "no-cache")
- s.fileHandler(s.browseSvc.GetThumbnail)(w, r)
+ s.fileHandler(s.media.Browse.GetThumbnail)(w, r)
}
func (s *Server) handleRegenThumbnail(w http.ResponseWriter, r *http.Request) {
- if !requireService(w, s.writeSvc) {
+ if !requireService(w, s.media.Write) {
return
}
id, err := pathID(r, "id")
@@ -93,7 +93,7 @@ func (s *Server) handleRegenThumbnail(w http.ResponseWriter, r *http.Request) {
badRequest(w, "invalid media id")
return
}
- if err := s.writeSvc.RegenerateThumbnail(r.Context(), id, userIDFromContext(r)); err != nil {
+ if err := s.media.Write.RegenerateThumbnail(r.Context(), id, userIDFromContext(r)); err != nil {
if errors.Is(err, service.ErrNotFound) {
notFound(w)
return