package api import ( "encoding/json" "net/http" "github.com/fujin/music-agregator/internal/database" "github.com/fujin/music-agregator/internal/metadata" "github.com/fujin/music-agregator/internal/services" "github.com/google/uuid" ) type Handlers struct { IndexerService *services.IndexerService TorrentService *services.TorrentService MetadataClient *metadata.Client DB *database.DB StorageBasePath string } func (h *Handlers) Health(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, map[string]string{"status": "ok"}) } func parseUUID(s string) (uuid.UUID, error) { return uuid.Parse(s) } func writeJSON(w http.ResponseWriter, status int, v any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) json.NewEncoder(w).Encode(v) } func writeError(w http.ResponseWriter, status int, message string) { writeJSON(w, status, map[string]string{"error": message}) }